Alphacode
Time Limit: 1000MS   Memory Limit: 30000K
Total Submissions: 11666   Accepted: 3564

Description

Alice and Bob need to send secret messages to each other and are discussing ways to encode their messages:

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

Input will consist of multiple input sets. Each set will consist of a single line of digits representing a valid encryption (for example, no line will begin with a 0). There will be no spaces between the digits. An input line of '0' will terminate the input and should not be processed

Output

For each input set, output the number of possible decodings for the input string. All answers will be within the range of a long variable.

Sample Input

25114
1111111111
3333333333
0

Sample Output

6
89
1
题目大意:将一个仅由大写字母组成的字符串,以每个字母的编号代替原字母,组成一个由0~9组成的数字序列。即1代替A,2代替B,10代替J等等。但是,将这个数字序列进行相同方式的解密,却有不止一个解。现给定一个某单词加密后的数字序列,问将这个数字序列解密后,会得到几种不同的单词。
#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std; int main()
{
char str[];
int dp[];
while(scanf("%s", str) != EOF && str[] != '')
{
memset(dp, , sizeof(dp));
dp[] = dp[] = ;
for (int i = ; i < strlen(str); i++)
{
if (str[i] == '')
{
dp[i + ] = dp[i - ];
}
else
{
if (str[i] - '' + (str[i - ] - '') * <= && str[i - ] != '')
{
dp[i + ] = dp[i] + dp[i - ];
}
else
{
dp[i + ] = dp[i];
}
}
}
printf("%d\n", dp[strlen(str)]);
}
return ;
}

POJ 2033 Alphacode的更多相关文章

  1. poj 2033 Alphacode (dp)

    Alphacode Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 13378   Accepted: 4026 Descri ...

  2. poj 动态规划题目列表及总结

    此文转载别人,希望自己能够做完这些题目! 1.POJ动态规划题目列表 容易:1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 11 ...

  3. poj动态规划列表

    [1]POJ 动态规划题目列表 容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1208, 1276, 13 ...

  4. POJ 动态规划题目列表

    ]POJ 动态规划题目列表 容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1208, 1276, 1322 ...

  5. poj 动态规划的主题列表和总结

    此文转载别人,希望自己可以做完这些题目. 1.POJ动态规划题目列表 easy:1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, ...

  6. [转] POJ DP问题

    列表一:经典题目题号:容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1191,1208, 1276, 13 ...

  7. POJ动态规划题目列表

    列表一:经典题目题号:容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1191,1208, 1276, 13 ...

  8. dp题目列表

    此文转载别人,希望自己能够做完这些题目! 1.POJ动态规划题目列表 容易:1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 11 ...

  9. DP题目列表/弟屁专题

    声明: 1.这份列表不是我原创的,放到这里便于自己浏览和查找题目. ※最近更新:Poj斜率优化题目 1180,2018,3709 列表一:经典题目题号:容易: 1018, 1050, 1083, 10 ...

随机推荐

  1. 【Python图像特征的音乐序列生成】图像特征在旋律生成中有什么用

    jishude 首先援引一个资料网页:http://www.cosmosshadow.com/ml/%E5%BA%94%E7%94%A8/2016/03/01/%E9%9F%B3%E4%B9%90%E ...

  2. SAP Cloud for Customer客户主数据的地图集成

    点击这个按钮可以通过地图的方式查看C4C客户在地图上的地理位置: 只需要在这个客户的地址栏里维护上天府软件园的经度和维度: 就能够在C4C的客户列表页面里显示该客户在地图上的位置: 要获取更多Jerr ...

  3. [CV笔记]OpenCV机器学习笔记

    KNN算法: 目的是分类,具体过程为,先训练,这个训练我估计只是对训练数据进行一个存储,knn测试的过程是根据测试样例找出与这个样例的距离最近的k个点,看这k个点中哪个分类所占的比例比较多,那么这个样 ...

  4. springboot 测试

    本次测试使用的是springboot 中的测试 1.(对service 的测试)下面的测试.将会启动容器进行测试 @RunWith(SpringRunner.class) @SpringBootTes ...

  5. java中的同步与异步

    在多线程的环境中,经常会碰到数据的共享问题,即当多个线程需要访问同一个资源时,它们需要以某种顺序来确保该资源在某--时刻只能被-一个线程使用,否则,程序的运行结果将会是不可预料的,在这种情况下就必须对 ...

  6. python之道10

    写函数,函数可以支持接收任意数字(位置传参)并将所有数据相加并返回. 答案 def func(*args): count = 0 for i in args: count += i return co ...

  7. c++ json字符串转换成map管理

    在cocos2dx for lua中,我们经常通过lua的table传入c++使用,然后早c++层操作数据. 实现步骤大致如下: table->string->c++层->通过rap ...

  8. 【转】浅谈对主成分分析(PCA)算法的理解

    以前对PCA算法有过一段时间的研究,但没整理成文章,最近项目又打算用到PCA算法,故趁热打铁整理下PCA算法的知识.本文观点旨在抛砖引玉,不是权威,更不能尽信,只是本人的一点体会. 主成分分析(PCA ...

  9. 网络流(一)——Edmonds Karp算法

    首先是一些关于网络流的术语: 源点:即图的起点. 汇点:即图的终点. 容量:有向边(u,v)允许通过的最大流量. 增广路:一条合法的从源点流向汇点的路径. 网络流问题是在图上进行解决的,我们通常可以将 ...

  10. CentOS 系统下Gitlab搭建与基本配置 以及代码备份迁移过程

    GitLab 是一个开源的版本管理系统,提供了类似于 GitHub 的源代码浏览,管理缺陷和注释等功能,你可以将代码免费托管到 GitLab.com,而且不限项目数量和成员数.最吸引人的一点是,可以在 ...