HDU1027 强大的STL
来源:互联网 发布:程序员出路 编辑:程序博客网 时间:2024/06/07 11:34
再一次见识到了STL的强大,,ORZ。。。
eg:b[3]={1,2,3};(有序)
有3!个全排列
next_permutation(b+0, b + 3); (递增)
The 3! possible permutations with 3 elements:1 2 31 3 22 1 32 3 13 1 23 2 1After loop: 1 2 3相对的有prev_permutation为递减
#include<cstdio>#include<stdlib.h>#include<string.h>#include<string>#include<map>#include<cmath>#include<iostream>#include <queue>#include <stack>#include<algorithm>#include<set>using namespace std;#define inf 2147483647#define eps 1e-8#define LL long long#define M 50005#define mol 1000000007int main(){int n,m;int a[]={0,1,2,6,24,120,720,5040,40320},b[1005]={0};while(~scanf("%d%d",&n,&m)){int i,j,k; for(i=0;i<10;i++) if(m>=a[i]&&m<=a[i+1]){ k=i+1;break; } for(j=1;j<=n-k;j++) printf("%d ",j); for(i=n-k+1,j=0;i<=n;i++,j++) { b[j]=i; } m--; while(m--) { next_permutation(b+0, b + k); } for(i=0;i<j-1;i++) printf("%d ",b[i]); printf("%d\n",b[j-1]);}return 0;}
- HDU1027 强大的STL
- 初识STL的强大
- hdu1027 next_permutation的应用
- hdu1027
- hdu1027
- hdu1027
- HDU1027
- hdu1027
- hdu1027 全排列(STL函数next_permutation)
- 强大的STL(一)
- 强大的STL(二)
- map, string 强大的STL
- 强大的STL之set
- stl里面的还真是强大
- STL的强大_文本的逆序转换
- c++ STL中元素替换功能的强大函数
- hdu1027 Ignatius and the Princess II (全排列 & STL中的神器)
- hdu1027(使用next_permutation求第m小的全排列)
- ArcGIS Engine 10开发环境的一些常见问题
- javaweb 之防盗链
- 百万级PHP网站架构工具箱
- Using dd as a Swiss Army knife
- linux shell 编程
- HDU1027 强大的STL
- (work and tools)ubuntu samba配置
- hdu-2023-求平均成绩
- no word
- 【转载】IT旅途——程序员面试经验分享
- Brief Intro to Container Literals of Foundation Framework
- vc--基于mfc的上位机设计(一)
- Ubuntu13.04环境下载、编译Android源代码
- 记录下FMDB的简单使用