Description
Alice: "Let's just use a very simple code: We'll assign 'A' the code word 1, 'B' will be 2, and so on down to 'Z' being assigned 26."
Bob: "That's a stupid code, Alice. Suppose I send you the word 'BEAN' encoded as 25114. You could decode that in many different ways!”
Alice: "Sure you could, but what words would you get? Other than 'BEAN', you'd get 'BEAAD', 'YAAD', 'YAN', 'YKD' and 'BEKD'. I think you would be able to figure out the correct decoding. And why would you send me the word ‘BEAN’ anyway?”
Bob: "OK, maybe that's a bad example, but I bet you that if you got a string of length 500 there would be tons of different decodings and with that many you would find at least two different ones that would make sense."
Alice: "How many different decodings?"
Bob: "Jillions!"
For some reason, Alice is still unconvinced by Bob's argument, so she requires a program that will determine how many decodings there can be for a given string using her code.
Input
Output
Sample Input
25114
1111111111
3333333333
0
Sample Output
6
89
1
题意: 现在要你做一项译码工作,A=1,B=2,C=3,...,Z=26.
解题思路:
代码:
#include
<cstdio>
#include <iostream>
#include <cstring>
using namespace std;
#define MAX 50005
int dp[MAX];
char str[MAX];
int main()
{
//
}