fork(1) download
  1. #include <cstdio>
  2. # include <cstring>
  3. char Input[5001] = "";
  4. unsigned long long DP[5001];
  5. int main()
  6. {
  7. scanf ("%s", Input);
  8. while (strcmp(Input, "0"))
  9. {
  10. int Len = strlen (Input), Index = 1;
  11. memset (DP, 0, sizeof DP);
  12. DP[0] = 1;
  13. while (Index < Len)
  14. {
  15. int temp = 0;
  16. temp = (Input[Index-1]-'0') * 10;
  17. temp += (Input[Index] -'0');
  18. if (Input[Index]-'0') DP[Index] = DP[Index-1];
  19. if (temp <= 26 && temp > 9) DP[Index] += DP[Index-2 < 0?0:Index-2];
  20. //printf ("%d\t%llu\n",Index, DP[Index]);
  21. Index++;
  22. }
  23. //printf ("%llu\t%s\n", DP[Len-1], Input);
  24. printf ("%llu\n", DP[Len-1]);
  25. scanf ("%s", Input);
  26. }
  27. }
Success #stdin #stdout 0s 3344KB
stdin
123123131351654984651321211655648411312331516849846132132135464848112312313135165498465132121165564841131233151684984613213213546484868498461321321354648481123123131351654984651321211655648411312331516849846132132135464848133
25114
1111111111
3333333333
1231231313516549846513212116556484113123315168498461321321354648481123123131351654984651321211655648411312331516849846132132135464848684984613213213546484811231231313516549846513212313135165498465132121165564841131233151684984613213213546484811231231313516549846513212116556484113123315168495165498465132121165564841131233151684984613213213546484811231231313516549846513212116556484113123315168498461321321354648486849846132132135464848112312313135165498465132121165564841131233151684984613213213546484813384613213213546484868498461321321354648481123123131351654984651321
0
stdout
12481083177021997056
6
89
1
10376293541461622784