Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iomanip>
- #include <iostream>
- #include <functional>
- #include <algorithm>
- #include <math.h>
- #include <cmath>
- #include <string>
- #include <cstring>
- #include <vector>
- #include<set>
- #include<map>
- #include <time.h>
- #include <fstream>
- using namespace std;
- pair <int,int> p[100006];
- bool cmp ( int a , int b )
- {
- return (a>b);
- }
- int a[1006];
- long long dp[5009];
- string s;
- int l;
- long long solve ( long long x )
- { if ( s[x]=='0' ) { return 0; }
- if ( dp[x]!=-1 ) { return dp[x]; }
- if ( x>=l ) { return 1; }
- //long long &ans = dp[x];
- dp[x] = 0;
- dp[x] += solve ( x+1 );
- if ( x<l-1&&(s[x] - '0') * 10 + (s[x] - '0')<=26 ) { dp[x] += solve ( x+2 ); }
- return dp[x];
- }
- int main()
- {int t=0;
- while (1)
- {
- cin>>s;
- if ( s=="0" ) { return 0; }
- if(t)cout<<endl;
- t=1;
- memset ( dp ,-1,sizeof dp );
- l = s.length();
- cout<<solve(0);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement