ACM: 动态规划题 poj 2033 (博客好…
来源:互联网 发布:mac安装jdk 编辑:程序博客网 时间:2024/06/04 19:04
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' beingassigned 26."
Bob: "That's a stupid code, Alice. Suppose I send you the word'BEAN' encoded as 25114. You could decode that in many differentways!”
Alice: "Sure you could, but what words would you get? Other than'BEAN', you'd get 'BEAAD', 'YAAD', 'YAN', 'YKD' and 'BEKD'. I thinkyou would be able to figure out the correct decoding. And why wouldyou send me the word ‘BEAN’ anyway?”
Bob: "OK, maybe that's a bad example, but I bet you that if you gota string of length 500 there would be tons of different decodingsand with that many you would find at least two different ones thatwould make sense."
Alice: "How many different decodings?"
Bob: "Jillions!"
For some reason, Alice is still unconvinced by Bob's argument, soshe requires a program that will determine how many decodings therecan 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()
{
//
}
- ACM: 动态规划题 poj 2033 (博客好…
- ACM: DP训练好题 动态规划题 poj 1…
- ACM: dp动态规划题(难) poj 3267 …
- ACM: dp题(动态规划) poj 2151 (d…
- ACM: 树状DP 动态规划题 poj 1463 …
- ACM: 简单动态规划题 poj 2955
- ACM: 动态规划题 poj 2241
- ACM: 动态规划题 poj 1054
- ACM: 动态规划题 poj 2948
- ACM: 动态规划题 poj 1925
- ACM: 动态规划题 poj 3034
- ACM: 动态规划题 poj 2411
- ACM: 动态规划题 poj 1947
- ACM: 动态规划题 poj 2486
- ACM: 动态规划题 poj 3140
- ACM: 动态规划题 poj 3659
- ACM: 动态规划题 poj 2923
- ACM: 动态规划题 poj 1191 Nothing…
- ACM:计划一个公司聚会 (大一时头疼…
- ACM:动态规划题 poj 1015
- ARM (一) arm寄存器
- ARM (二) arm指令分类及其寻址方式
- ARM (三) arm中C/C++及汇编语言的…
- ACM: 动态规划题 poj 2033 (博客好…
- ACM: 动态规划题 poj 1036 问题简…
- ACM: 划分树 poj 2104
- ACM: 划分树 poj 2761 在poj2104基…
- ACM: 最小堆 poj 2227 最小堆 fro…
- ACM: 最小堆 poj 2274 思路清晰, …
- ACM: 线段树 poj 2352
- ACM: 线段树 poj 1151 足足想了三…
- 运算符与表达式