暴力求字典序
来源:互联网 发布:淘宝网牛仔连衣裙新款 编辑:程序博客网 时间:2024/06/07 02:57
#include<cstdio>
#include<algorithm> //包含next_permutation
using namespace std;
int main( ) {
int n, p[10];
scanf("%d", &n);
for(int i = 0; i < n; i++) scanf("%d", &p[i]);
sort(p, p+n); //排序,得到p的最小排列
do {
for(int i = 0; i < n; i++) printf("%d ", p[i]); //输出排列p
printf("\n");
} while(next_permutation(p, p+n)); //求下一个排列
return 0;
}
#include<algorithm> //包含next_permutation
using namespace std;
int main( ) {
int n, p[10];
scanf("%d", &n);
for(int i = 0; i < n; i++) scanf("%d", &p[i]);
sort(p, p+n); //排序,得到p的最小排列
do {
for(int i = 0; i < n; i++) printf("%d ", p[i]); //输出排列p
printf("\n");
} while(next_permutation(p, p+n)); //求下一个排列
return 0;
}
阅读全文
0 0
- 暴力求字典序
- 2-SAT DFS暴力求最小字典序的模板(Peaceful Commission)
- 字典序问题(暴力)
- 【HDU5536 2015长春赛区 J】【字典树or暴力】Chip Factory 字典序做法+暴力做法
- HDU-1015-Safecracker(Java && 暴力大法好 && 简单字典序)
- LexicographicPermute(求字典序的下一个字典序)
- 求字典序最小解+贪心
- Floyd求字典序最小的路径
- 一串字符求最小字典序
- 求字典序的下一个全排列
- 最小表示法, 求字典序最小
- 暴力求解法入门
- 暴力求解法
- 暴力求解法 最大乘积
- 暴力求解法--简单枚举
- 暴力求解法-简单枚举
- Harmonic Number(暴力求解法)
- 暴力求解法--生成子集
- docker在linux安装
- 设计模式:6大设计原则
- Nanopi2-(3)关键电路摘要
- jsonp学习记录
- D
- 暴力求字典序
- 玩客云挖矿之旅
- 【C2】在HTML中使用JavaScript
- 20171217---Day016
- 【树链剖分+李超线段树】BZOJ4515(Sdoi2016)[游戏]题解
- pytorch-yolo2-master运行日志
- netty源码分析之-处理器详解(13)
- HDU 1728 逃离迷宫【BFS】
- leetcode 532. K-diff Pairs in an Array