排列组合之next_permutation函数的运用
来源:互联网 发布:黑暗之光骑兽升阶数据 编辑:程序博客网 时间:2024/05/17 20:35
poj1146:http://poj.org/problem?id=1146
#include<iostream>#include<cstring>#include<algorithm>using namespace std;int main(){ char a[61]; while(cin>>a) { if(a[0]=='#')break; else if(next_permutation(a,a+strlen(a)))cout<<a<<endl; else cout<<"No Successor"<<endl; } return 0;}
//注意在输出字母的时候不要输出错误,不要把o写成0即可,特别注意,字符串的排列可以直接用next_permutation函数处理,记得要包含头文件#include<algorithm>
poj1833:http://poj.org/problem?id=1833
#include<iostream>#include<cstdio>#include<algorithm>using namespace std;int main(){ int n1,n,k,i,j,a[1024]; scanf("%d",&n1); while(n1--) { cin>>n>>k; for(i=0;i<n;i++,j++) { scanf("%d",&j); a[i]=j; } for(i=0;i<k;i++) next_permutation(a,a+n); for(i=0;i<n;i++) printf("%d ",a[i]); printf("\n"); } return 0;}
//这题必须要用c语言的输入输出的方法,否则的话会超时处理
与该题类似的还有poj1256,poj2436(较难),poj2249,poj1019,poj3252,poj1850
- 排列组合之next_permutation函数的运用
- next_permutation(排列组合)函数的用法
- next_permutation(排列组合)函数的用法
- 蓝桥杯之全排列函数next_permutation()运用
- 排列组合的求法&next_permutation
- POJ 1833 排列 next_permutation函数的运用,简单模拟题
- Python的排列组合运用
- 指数型母函数运用的实例(排列组合)
- hdu 1027 全排列函数next_permutation运用
- next_permutation的函数
- next_permutation函数的使用
- next_permutation函数的应用
- next_permutation 函数的应用
- STL的next_permutation函数
- UVA 146 ID code(next_permutation的运用)
- bzoj1925(next_permutation的第一次运用,难dp)
- 全排列(STL之next_permutation函数的应用)
- C#语法灵活运用之排列组合算法
- sql计算(,1,2,3,4,)中有几个数字
- Fedora进入超级用户的方法
- zen cart首页与产品页各个页面 显示单栏双栏三栏的方法
- 通用归并排序
- css3 background-size 用法
- 排列组合之next_permutation函数的运用
- GIS底层开发的定义
- 打印图形
- java 连mysql接数据库一个简单实例
- DB2的MERGE语句使用注意事项!
- iphone cocos2d下载和安装
- Linux设备驱动之I2C架构分析
- 最受欢迎的ASP.NET的CMS下载
- Streaming vs. progressive download: Understanding the difference