Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <math.h>
- #include <string>
- #include <algorithm>
- #include <bitset>
- #include <stack>
- #include <sstream>
- #include <map>
- using namespace std;
- int main(int argc, const char * argv[])
- {
- while (true) {
- string str;
- cin >> str;
- if (str == "0")break;
- long long DP[5001];
- DP[0] = 1;
- for (int i=1;i<str.length();i++) {
- int temp = (str[i-1]-'0')*10;
- temp += (str[i]-'0');
- if (str[i]-'0')DP[i] += DP[i-1];
- if (temp <= 26 && temp > 9 )DP[i] += i>1? DP[i-2]: DP[0];
- //cout << "substring: " << str.substr(0, i+1) << " now equal: " << DP[i] << endl;
- }
- cout << DP[str.length()-1] << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement