poj 2033 Alphacode
2015-07-06 18:23
323 查看
确定第i+2 个元素与第i个元素和第i+1的元素的关系即可
/* #include<iostream> #include<string.h> #include<math.h> #include<fstream> #include<algorithm> #include<stdio.h> #include<queue> #include<vector> #define MAXSIZE 100 using namespace std; typedef long long int ll; ll a = 0; int dat[100000010]; int dp[10000010]; int ind = 0; void getEverynum() { while(a) { int t = a % 10; dat[ind++] = t; a = a / 10; } } int main() { freopen("data_2033.txt","r",stdin); while(true) { ind = 1; memset(dat, 0, sizeof(dat)); memset(dp, 0, sizeof(dp)); scanf("%d", &a); if (a == 0) { break; } getEverynum(); //dp[1] = 1; for (int i = 1; i < ind; i++) { if (dat[i + 1] < '7') { dp[i + 1] = dp[i] + 2; i += 1; }else { dp[i + 1] = max (dp[i] + 1, dp[i - 1] + 2); } } printf("%d\n", dp[ind]); } return 0; }*/ #include<iostream> #include<string.h> #include<math.h> #include<fstream> #include<algorithm> #include<stdio.h> #include<queue> #include<vector> #define MAXSIZE 100 using namespace std; int dp[100010]; int main() { //freopen("data_2033.txt","r",stdin); char s[100010]; while(true) { scanf("%s", s); if (s[0] == '0') { break; } dp[0] = 1; dp[1] = 1; for (int i = 2; i <= strlen(s); i++) { dp[i] = 0; if (s[i - 1] != 48) { dp[i] += dp[i - 1]; } if (s[i - 1] - 48 + s[i - 2] * 10 - 480 <= 26 && s[i - 2] != 48) { dp[i] += dp[i - 2]; } } printf("%d\n", dp[strlen(s)]); } return 0; }
相关文章推荐
- CentOS 5 安装 saltstack
- plupload批量上传分片(后台代码)
- Linux 基础命令知识2
- intellij idea 13&14 插件推荐及快速上手建议
- 新点
- Rails 异常处理 && 性能
- visual studio 2008中 error LNK2005的解决方法
- 1 - 简介
- LeetCode OJ 33 Search in Rotated Sorted Array
- PowerShell创建虚拟机 (一、基本思路与实现代码)
- 90.按要求打印二维数组
- 如何使用 TP中的公共函数 (定义在common/common.php中的函数)
- 阿里巴巴贷款信誉曝光
- DELL R420真机搭建LAMP环境
- DELL R420真机搭建LAMP环境
- NGUI学习总结
- unity5.0利用自带UI制作滚动条
- Android Studio使用笔记(随时添加)
- ubuntu下安装eclipse IDE for C/C++ developers
- ThinkSNS 缓存数据原理简单研究