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. 洛谷 P2014 选课

    题目描述 在大学里每个学生,为了达到一定的学分,必须从很多课程里选择一些课程来学习,在课程里有些课程必须在某些课程之前学习,如高等数学总是在其它课程之前学习.现在有N门功课,每门课有个学分,每门课有一 ...

  2. PHP生成类似类似优酷、腾讯视频等其他视频链的ID

    不知道你注意了没有,类似优酷.腾讯视频等其他视频链接似乎类似这样的 http://v.youku.com/v_show/id_XNjA5MjE5OTM2.html 注意id_xxx那段,是不是看不懂了 ...

  3. Spark性能调优之道——解决Spark数据倾斜(Data Skew)的N种姿势

    原文:http://blog.csdn.net/tanglizhe1105/article/details/51050974 背景 很多使用Spark的朋友很想知道rdd里的元素是怎么存储的,它们占用 ...

  4. mysql数据库操作手册

      1 存储过程的写法 以下是一个带有入参的存储过程模板, #删除方案-存储过程 CREATE PROCEDURE procPersonAppointRecallPlanByPlanUuidDelet ...

  5. eubacteria|endosymbiosis|基因转移

    5.11线粒体和叶绿体是通过内共生进化而来的 初始细胞俘获有功能的真细菌(eubacteria)进入细胞内,该细菌逐渐演化为细胞器,这种现象称为内共生(endosymbiosis),所以该细胞器携带细 ...

  6. C++内存管理(effective c++ 04)

    阅读effective c++ 04 (30页) 提到的static对象和堆与栈对象.看了看侯老师的内存管理视频1~3.有点深. 了解一下. 目录 1 内存管理 1.1 C++内存管理详解 1.1.1 ...

  7. Java语言中的异常处理

    Java语言中的异常处理包括声明异常.抛出异常.捕获异常和处理异常四个环节.   throw用于抛出异常.   throws关键字可以在方法上声明该方法要抛出的异常,然后在方法内部通过throw抛出异 ...

  8. 【线段树 树链剖分 差分 经典技巧】loj#3046. 「ZJOI2019」语言【未完】

    还是来致敬一下那过往吧 题目分析 先丢代码 #include<bits/stdc++.h> ; ; ; struct node { int top,son,fa,tot; }a[maxn] ...

  9. 初涉网络流[EK&dinic]

    主要还是板子 Edmonds-Karp 从S开始bfs,直到找到一条到达T的路径后将该路径增广,并重复这一过程. 在处理过程中,为了应对“找到的一条路径把其他路径堵塞”的情况,采用了建反向弧的方式来实 ...

  10. [JZOJ] 5837.Omeed

    先摆出来这个式子 \[ score=A\sum S_i+B\sum S_i\times f(i) \] 先研究\(f\)函数(也就是Combo函数) 显然的有 \[ f(i)=P_i(f(i-1)+1 ...