POJ 1496 Word Index (组合数学 求字符串对应编码)
来源:互联网 发布:seo服务cao4 编辑:程序博客网 时间:2024/05/24 22:42
题目链接
POJ1496
分析
此题同POJ1850。
无非就是输入输出变多组。直接上代码。
代码
#include <iostream>#include <string>using namespace std;int c[27][27],len;void Make_C(){ for (int i=0;i<=26;i++) for (int j=0;j<=i;j++) if (!j||i==j) c[i][j]=1; else c[i][j]=c[i-1][j-1]+c[i-1][j];}int Code(string str){ int sum=0,i; /*计算长度比ch小的字符串总共有多少个*/ for (i=1;i<=len-1;i++) sum+=c[26][i]; /*计算长度等于ch且在ch前面的字符串总共有多少个*/ for (i=0;i<len;i++) { char ch=(!i)?'a':str[i-1]+1; while (ch<=str[i]-1) { sum+=c['z'-ch][len-1-i]; ch++; } } return sum+1;}int main(){ string str; int i; bool flag; Make_C(); while (cin>>str) { len=str.length(); flag=true; for (i=0;i<len-1;i++) if (str[i]>=str[i+1]) { flag=false; break; } if (flag) cout<<Code(str)<<endl; else cout<<0<<endl; } return 0;}
0 0
- POJ 1496 Word Index (组合数学 求字符串对应编码)
- POJ 1085 Code (组合数学 求字符串对应编码)
- poj 1496 Word Index 计数/组合数学
- POJ 1850 Code && 1496 Word Index 组合数学
- POJ 1496 Word Index组合数学(解题报告)
- POJ 1850 Code/POJ 1496 Word Index(组合数学-字母串序号)
- Poj 1496 Word Index & Poj 1850 Code (计数 组合数)
- POJ 1850 Code ,1496 Word Index(组合计数)
- [ACM] poj 1496 Word Index(组合计数)
- POJ 1496 Word Index
- POJ 1496 Word Index
- POJ 1496 Word Index 笔记
- POJ 1496 Word Index || POJ 1850 Code
- POJ 1850 Code POJ 1496 Word Index
- POJ 1850/ 1496 组合数学
- POJ 题目1496 Word Index(排列组合)
- (Relax 数论1.26)POJ 1496 Word Index(计算一个字符串在字典中的位置)
- POJ1469 Word Index (组合数)
- c++作业2-简单程序设计
- Hibernate一对多映射
- Android中的Selector的用法
- 3-4 Python中什么是变量
- 使用for九九乘法表
- POJ 1496 Word Index (组合数学 求字符串对应编码)
- 如何更新 OpenStack 组件?- 每天5分钟玩转 OpenStack(161)
- 复习
- bzoj1620
- Problem H: 平面上的点和线——Point类、Line类 (IV)
- Hibernate查询语句HQL
- thinkphp网站提示缓存文件写入失败
- 关于Graphx中的pregel的API理解
- 【BZOJ 1058】【ZJOI 2007】报表统计【Treap】