qdu 26 —— 康拓展开
来源:互联网 发布:使用python ddos攻击 编辑:程序博客网 时间:2024/06/09 17:53
排在第几个
发布时间: 2015年10月10日 18:05 时间限制: 1000ms 内存限制: 256M
现在有"abcdefghijkl”12个字符,将其所有的排列中按字典序排列,给出任意一种排列,说出这个排列在所有的排列中是第几小的?
每行输入一行字符串,保证是a~l这12个字符的某种排列
EOF结束
输出一个整数,代表这个排列排在第几位
复制
abcdefghijklabcdefghikljgfkedhjblcia
14260726926
康拓模板题
#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>#include <queue>#include <stack>#include <map>#include <cmath>#include <vector>#define max_ 10010#define inf 0x3f3f3f3f#define ll long longusing namespace std;int f[13];char tmp[13]={"abcdefghijkl"};char sent[max_];int main(int argc, char const *argv[]){int i,j;f[0]=f[1]=1;for(i=2;i<=12;i++)f[i]=f[i-1]*i;while(scanf(" %s",sent)!=EOF){ll sum=0;for(i=0;i<12;i++){int cnt=0;for(j=i+1;j<12;j++)if(sent[i]>sent[j])cnt++;sum=sum+f[12-i-1]*cnt;}printf("%lld\n",sum+1 );}}
阅读全文
0 0
- qdu 26 —— 康拓展开
- QDU第二次月赛 排在第几个(康拓展开)
- 康拓展开—理解
- 康拓展开 & 逆康拓展开
- 康拓展开&&逆康拓展开
- 康拓展开 & 逆康拓展开
- 康拓展开,康拓展开逆运算
- 康拓展开
- 逆康拓展开
- 康拓展开
- 康拓展开
- 康拓展开逆运算
- 康拓展开
- 康拓展开
- 康拓展开
- 康拓展开 Test
- 康拓展开
- 康拓展开
- python 序列化数据:pickle与json ,dumps与loads
- 解决小米手机Android Studio安装app 报错的问题It is possible that this issue is resolved by uninstalling an existi
- 判断js中的数据类型
- this指向
- 写给自己的JAVA工程师之路-异常
- qdu 26 —— 康拓展开
- 《0day安全学习笔记》——ChapterII——覆盖返回地址
- 内存释放五大内存分区
- 利用python进入数据分析之Numpy基础知识
- 关于”#”操作符在lua中table的运用
- Spring Data redis序列化的比较
- 解决wordpress不能上传图片的权限限制问题,亲测有效
- 支付宝花呗不推荐使用,因为我已经帮你算好账了
- 作业.找出汉字“你“”我“”他”的位置