HDU 1027 Ignatius and the Princess II (next_permutation)
来源:互联网 发布:域名续费可以改地方吗 编辑:程序博客网 时间:2024/05/21 22:38
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1027
题目大意: 给你一个N个元素的序列为1,2,3……n-1,n组成一个排列。 问第M大的排列顺序为多少
解题思路:直接用STL中的next_permutation
next_permutation用法:next_permutation(num, num+n);
#include<cstdio>#include<cstring>#include<algorithm>#include<iostream>using namespace std;const int maxn = 1111;int num[maxn];int main (){ int n, m; while(scanf("%d %d", &n, &m) != EOF) { for(int i = 0; i < n; i++) num[i] = i+1; for(int i = 1; i < m; i++) next_permutation(num, num+n); for(int i = 0; i < n; i++) { if(i == n-1) printf("%d\n", num[i]); else printf("%d ", num[i]); } } return 0;}
0 0
- next_permutation & prev_permutation & hdu 1027 Ignatius and the Princess II
- HDU 1027 Ignatius and the Princess II (next_permutation)
- HDU 1027--Ignatius and the Princess II【next_permutation】
- HDU 1027 Ignatius and the Princess II(stl,next_permutation)
- HDU 1027 Ignatius and the Princess II【STL- next_permutation全拍列】
- Ignatius and the Princess II( next_permutation() )
- HDOJ 1027 Ignatius and the Princess II - next_permutation函数
- HDUOJ 1027 Ignatius and the Princess II(next_permutation)
- Ignatius and the Princess II (HDU 1027) ——next_permutation排列函数
- HDU 1027 Ignatius and the Princess II 【next_permutation(a,a+n)的应用】
- HDU——1027Ignatius and the Princess II(next_permutation函数)
- HDU.1027 Ignatius and the Princess II【全排列:关于next_permutation问题】(3.14)
- HDU 1027 Ignatius and the Princess II next_permutation函数(也可以用DFS......)
- HDU 1027 Ignatius and the Princess II(next_permutation()的应用)
- HDU 1027 Ignatius and the Princess II(全排列next_permutation函数)
- hdu 1027 ignatius and the princess ii
- HDU 1027 Ignatius and the Princess II
- HDU 1027 ( Ignatius and the Princess II )
- oracle相关汇总
- android ExpandableListView 简单实例
- QEMU KVM Libvirt手册(6) – Network Block Device
- Weka源码分析(1)逆向工程Eclipse插件ObjectAid和AmaterasUML的安装方法
- 关于U-Boot中的u-boot中的.balignl 16,0xdeadbeef
- HDU 1027 Ignatius and the Princess II (next_permutation)
- 通用权限管理设计
- Oracle BEGIN END
- dom4j 生成xml 并将其格式化
- 进入Material Design时代
- 解决windows中文冲突
- QEMU KVM Libvirt手册(7): 硬件虚拟化
- QEMU KVM Libvirt手册(8): 半虚拟化设备virtio
- Android API文档 GridView