fork(1) download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. char s[50001];
  4. int len;
  5. int dp[99][50001];
  6. int rec(int val,int pos)
  7. {
  8.  
  9. if(val<1||val>26)
  10. return 0;
  11. if(pos>=len-1)
  12. return 1;
  13. if(dp[val][pos]!=-1)
  14. return dp[val][pos]=rec(s[pos]-48,pos+1)+rec((s[pos]-48)*10+(s[pos+1]-48),pos+2);
  15. }
  16.  
  17. int main()
  18. {
  19. while(1){
  20. scanf("%s",s);
  21. if(s[0]=='0')
  22. break;
  23. for(int i=0;i<99;i++)
  24. {
  25. for(int j=0;j<50001;j++)
  26. dp[i][j]=-1;
  27. }
  28. len=strlen(s);
  29. int ans=rec(1,0);
  30.  
  31.  
  32.  
  33. cout<<ans<<"\n";
  34.  
  35. }
  36. return 0;
  37. }
  38.  
Success #stdin #stdout 0s 35448KB
stdin
25114
0
stdout
1