Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <stack>
  6. #include <list>
  7. #include <cstring>
  8. #include <string>
  9. #include <string.h>
  10.  
  11. using namespace std;
  12.  
  13. long long stepen(int a, int b)
  14. {
  15.     long long q=1;
  16.     for (int i=0; i<b; i++)
  17.     {
  18.         q*=a;
  19.     }
  20.     return q;
  21. }
  22.  
  23. long long faktoriel(int a, vector<int> x)
  24. {
  25.     sort(x.rbegin(), x.rend());
  26.     long long q=1;
  27.     int k=1;
  28.     for (int i=a; i>x[0]; i--)
  29.     {
  30.         q*=i;
  31.         if (k<4 && q%x[k]==0)
  32.         {
  33.             q/=x[k];
  34.             k++;
  35.         }
  36.         q%=1000000007;
  37.     }
  38.     return q;
  39. }
  40.  
  41. int main()
  42. {
  43.     vector<long long> count;
  44.     string s;
  45.     cin >> s;
  46.     if (s[s.size()-1]!='0')
  47.     {
  48.         count.push_back(1);
  49.     }
  50.     else
  51.     {
  52.         count.push_back(0);
  53.     }
  54.     if (s[s.size()-2]=='0')
  55.     {
  56.         count.push_back(0);
  57.     }
  58.     else if (s.size()>1 && s[s.size()-1]!='0' && ((s[s.size()-2]=='1' || (s[s.size()-2]=='2' && s[s.size()-1]<'7'))))
  59.     {
  60.         count.push_back(2);
  61.     }
  62.     else
  63.     {
  64.         count.push_back(1);
  65.     }
  66.     for (int i=s.size()-3; i>=0; i--)
  67.     {
  68.         if (s[i]=='0')
  69.         {
  70.             count.push_back(0);
  71.         }
  72.         else if (s[i]=='1' || (s[i]=='2' && s[i+1]<'7'))
  73.         {
  74.             if (s[i+1]!='0')
  75.             {
  76.                 count.push_back(count[count.size()-2]+count[count.size()-1]);
  77.             }
  78.             else
  79.             {
  80.                 count.push_back(count[count.size()-2]);
  81.             }
  82.         }
  83.         else
  84.         {
  85.             count.push_back(count[count.size()-1]);
  86.         }
  87.     }
  88.     cout << count[count.size()-1];
  89.     return 0;
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement