fork download
  1. #include <bits/stdc++.h>
  2. using namespace std ;
  3. unsigned long long fib[86];
  4. int main()
  5. {
  6. fib[0] = 0 , fib[1] = 1;
  7. for (int i = 2 ; i <= 85 ; i++ )
  8. {
  9. fib[i] = fib[i-1] + fib[i-2];
  10. }
  11. cout << fib[4];
  12. string s;
  13. while(cin >> s)
  14. {
  15. unsigned long long res = 1,c = 1;
  16. if (s == "0") break;
  17. for (int i = 0 ; i < s.size() - 1 ; i++ )
  18. {
  19. int n = (s[i] - 48 )*10 + (s[i+1] - 48 );
  20. if ( i+ 2 < s.size() && s[i+2] == '0') res *= fib[++c] , c = 1;
  21. else if ( s[i + 1] == '0') i ++ , res *= fib[++c] , c = 1;
  22. else if (n <= 26) c++;
  23. else
  24. {
  25. res *= fib[++c] , c = 1;
  26. }
  27. }
  28. int check = s.find("00");
  29. if (check >= 0) res = 0;
  30. cout << res * fib[++c]<< "\n";
  31. }
  32. }
  33.  
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
3