Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- string s;
- int dp[255];
- int kod(int i) {
- if(i >= s.size()) {
- return 1;
- }
- if(dp[i] != -1) {
- return dp[i];
- }
- int result = 0;
- if(i + 1 < s.size() and s[i] != '0') {
- int broj = (s[i] - '0') * 10 + (s[i + 1] - '0');
- if(broj <= 26) {
- result += kod(i + 2);
- }
- }
- if(s[i] != '0') {
- result += kod(i + 1);
- }
- dp[i] = result;
- return result;
- }
- int main() {
- cin >> s;
- for(int i = 0; i < 251; i++) {
- dp[i] = -1;
- }
- cout << kod(0) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement