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. NVM for Windows下载与安装

    下载NVM for Windows https://github.com/coreybutler/nvm-windows/releases nvm-noinstall.zip: 这个是绿色免安装版本, ...

  2. 洛谷 P1145 约瑟夫

    题目描述 n个人站成一圈,从某个人开始数数,每次数到m的人就被杀掉,然后下一个人重新开始数,直到最后只剩一个人.现在有一圈人,k个好人站在一起,k个坏人站在一起.从第一个好人开始数数.你要确定一个最小 ...

  3. (五)SpringMVC之使用Kaptcha实现验证码功能

    一.什么是Kaptcha Kaptcha是Google开发的用于自动生成验证码的插件. 二.怎么导入Kaptcha ① 如果没有用Maven管理工具的话就直接导入包(可以直接下载:pau8) http ...

  4. Webpack 10分钟入门

    可以说现在但凡开发Single page application,webpack是一个不可或缺的工具. WebPack可以看做是一个模块加工器,如上图所示.它做的事情是,接受一些输入,经过加工产生一些 ...

  5. springmvc 的原理分析

    1. 用户发送请求至前端控制器(DispatcherServlet) 2.DispatcherServlet 将受到的请求调用HandlerMapping 处理映射器 3.处理器映射器根据配置注解找到 ...

  6. Cenos7—安装

    1. 进入安装界面 2. 选择语言 3. 进行分区 4. 设置root密码

  7. 面向对象OONo.3单元总结

    一,JML语言 1)JML理论基础:JML是一类语言,用来描述一个方法或一个类的功能.以及这个类在实现这个功能时需要的条件.可能改变的全局变量.以及由于条件问题不能实现功能时这个方法或类的行为,具有明 ...

  8. 解决Error"基础连接已经关闭: 未能为SSL/TLS 安全通道建立信任关系

    今天写程序的时候调用到一个第三方的DLL文件,本机调试一切都正常,但是程序不是到服务器以后一直提示一个BUG:"基础连接已经关闭: 未能为SSL/TLS 安全通道建立信任关系".  ...

  9. 【转】BP神经网络

    学习是神经网络一种最重要也最令人注目的特点.在神经网络的发展进程中,学习算法的研究有着十分重要的地位.目前,人们所提出的神经网络模型都是和学习算 法相应的.所以,有时人们并不去祈求对模型和算法进行严格 ...

  10. MYSQL不能显示中文字,显示错误“ERROR 1366 (HY000): Incorrect string value: '\xE5\xBC\xA0\xE4\xB8\x89'”

    或者建表时带上编码utf8 CREATE TABLE `students`( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `name` VARCHAR( ...