Advertisement
AquaBlitz11

Alphabet Encoding

Mar 24th, 2019
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int N = 100010;
  5. char str[N];
  6. int dp[N];
  7.  
  8. int main()
  9. {
  10.     scanf("%s", str+1);
  11.     int n = strlen(str+1);
  12.     dp[0] = 1;
  13.     dp[1] = str[1] != '0' ? 1 : 0;
  14.     for (int i = 2; i <= n; ++i) {
  15.         if (str[i] != '0')
  16.             dp[i] += dp[i-1];
  17.         int v = (str[i-1]-'0')*10 + (str[i]-'0');
  18.         if (v >= 10 && v <= 26)
  19.             dp[i] += dp[i-2];
  20.         dp[i] %= 85142019;
  21.     }
  22.     printf("%d\n", dp[n]);
  23.  
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement