Advertisement
jeff69

Untitled

Apr 4th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #include <iomanip>
  2. #include <iostream>
  3. #include <functional>
  4. #include <algorithm>
  5. #include <math.h>
  6. #include <cmath>
  7. #include <string>
  8. #include <cstring>
  9. #include <vector>
  10. #include<set>
  11. #include<map>
  12. #include <time.h>
  13. #include <fstream>
  14.  
  15. using namespace std;
  16.  
  17. pair <int,int> p[100006];
  18.  
  19. bool cmp ( int a , int b )
  20. {
  21. return (a>b);
  22. }
  23.  
  24.  
  25. int a[1006];
  26.  
  27. long long dp[5009];
  28.  
  29.  
  30. string s;
  31. int l;
  32.  
  33.  
  34.  
  35. long long solve ( long long x )
  36. { if ( s[x]=='0' ) { return 0; }
  37. if ( dp[x]!=-1 ) { return dp[x]; }
  38. if ( x>=l ) { return 1; }
  39.  
  40.  
  41. //long long &ans = dp[x];
  42. dp[x] = 0;
  43. dp[x] += solve ( x+1 );
  44. if ( x<l-1&&(s[x] - '0') * 10 + (s[x] - '0')<=26 ) { dp[x] += solve ( x+2 ); }
  45.  
  46. return dp[x];
  47.  
  48. }
  49.  
  50.  
  51. int main()
  52. {int t=0;
  53.  
  54.  
  55. while (1)
  56. {
  57.  
  58. cin>>s;
  59. if ( s=="0" ) { return 0; }
  60. if(t)cout<<endl;
  61. t=1;
  62. memset ( dp ,-1,sizeof dp );
  63.  
  64.  
  65. l = s.length();
  66.  
  67. cout<<solve(0);
  68. }
  69.  
  70.  
  71.  
  72.  
  73. return 0;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement