poj1850-CODE-组合
2016-01-29 11:17
369 查看
求出给定序列的序号。有一个定理需要知道
![](http://images2015.cnblogs.com/blog/761792/201601/761792-20160129111545677-1346658470.jpg)
具体看这篇博客吧/article/1968930.html
![](http://images2015.cnblogs.com/blog/761792/201601/761792-20160129111545677-1346658470.jpg)
具体看这篇博客吧/article/1968930.html
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; char str[20]; int ans=0,C[26][26]; void init(void) { 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]; C[0][0]=0; return; } int main() { init(); while(~scanf("%s",str)) { int len = strlen(str); char oc = str[0],nc = str[0]; int ok = 1; ans=0; for(int i=1;i<len;i++) { nc = str[i]; if(nc <= oc) { printf("0\n"); ok = 0; break; } } if(!ok) continue; for(int i=1;i<len;i++) ans += C[26][i]; for(int i=0;i<len;i++) { char ch = i?str[i-1]+1:'a'; while(ch < str[i]) { ans += C['z'-ch][len-1-i]; ch++; } } printf("%d\n",ans+1); } }
相关文章推荐
- 滚动7天TOP 模型
- dubbo支持rest,远程调用的场景
- Cloud Test 在手,宕机时让您不再措手不及
- maven tomcat plugin实现热部署
- FastRCNN 训练自己数据集 (1编译配置)
- 获取真实IP的方法,以及伪造IP的例子代码
- linux下mysql数据的导出和导
- freetype2.0 在hi3516A/hi3516D上的应用(一)
- Django Admin:添加富文本编辑器kindeditor
- 【监控】使用probe对tomcat服务进行监控
- java.io.IOException: No such file or directory解决方案之权限问题
- leetcode刷题系列C++-Search in Rotated Sorted Array II
- 存在导航栏时UITextView 上面空白 光标下移
- Windows 下 pdf2word 的可用软件记录
- 查看linux占用内存/CPU最多的进程
- list与数组转化
- 从 Option Explicit 开始的零碎知识点(三)
- mysql 常用option
- CIC许可更新
- find命令的总结