Untitled

mail@pastecode.io avatar
unknown
c_cpp
3 years ago
573 B
0
Indexable
Never
#include <iostream>
using namespace std;

string s;
int memo[255];

int main()
{
    cin >> s;
    for(int i = 0; i <= s.length(); i++) {
        memo[i] = 0;
    }
    memo[0] = 1;
    memo[1] = 1;
    for(int x = 1; x < s.length(); x++) {
        if(s[x] != '0') {
            memo[x + 1] = memo[x];
        }
        if(s[x - 1] != '0') {
            int number = (s[x - 1] - '0') * 10 + (s[x] - '0');
            if(number <= 26) {
                memo[x + 1] += memo[x - 1];
            }
        }
    }
    cout << memo[s.length()] << endl;
    return 0;
}

// 2504