nyoj 366-D的小L (next_permutation())
Next nyoj Permutation
2023-09-11 14:21:11 时间
366-D的小L
内存限制:64MB
时间限制:4000ms
特判: No
通过数:5
提交数:7
难度:2
题目描述:
一天TC的匡匡找ACM的小L玩三国杀,但是这会小L忙着哩,不想和匡匡玩但又怕匡匡生气,这时小L给匡匡出了个题目想难倒匡匡(小L很D吧
),有一个数n(0<n<10),写出1到n的全排列,这时匡匡有点囧了
,,,聪明的你能帮匡匡解围吗?
![](http://59.69.128.200/JudgeOnline/admin/kind/plugins/emoticons/44.gif)
![](http://59.69.128.200/JudgeOnline/admin/kind/plugins/emoticons/18.gif)
输入描述:
第一行输入一个数N(0<N<10),表示有N组测试数据。后面的N行输入多组输入数据,每组输入数据都是一个整数x(0<x<10)
输出描述:
按特定顺序输出所有组合。 特定顺序:每一个组合中的值从小到大排列,组合之间按字典序排列。
样例输入:
2 2 3
样例输出:
12 21 123 132 213 231 312 321
C/C++ AC:
1 #include <iostream> 2 #include <algorithm> 3 #include <cstring> 4 #include <cstdio> 5 #include <cmath> 6 #include <stack> 7 #include <set> 8 #include <map> 9 #include <queue> 10 #include <climits> 11 #define PI 3.1415926 12 13 using namespace std; 14 const int MY_MAX = 35; 15 int N, m[MY_MAX]; 16 17 int main() 18 { 19 cin >>N; 20 while (N --) 21 { 22 int temp, A[15]; 23 cin >>temp; 24 for (int i = 0; i < temp; ++ i) 25 { 26 A[i] = i + 1; 27 } 28 29 do 30 { 31 for (int i = 0; i < temp; ++ i) 32 printf("%d", A[i]); 33 printf("\n"); 34 } while(next_permutation(A, A+temp)); 35 } 36 }
相关文章
- Mysql加锁过程详解(9)-innodb下的记录锁,间隙锁,next-key锁
- Mysql加锁过程详解(8)-理解innodb的锁(record,gap,Next-Key lock)
- hdu3746 KMP的next数组应用,求项链首尾项链循环
- Leetcode: Populating Next Right Pointers in Each Node II
- [转] 对express中next函数的一些理解
- python内置函数next()方法用法详解
- 第四十三章 Caché 函数大全 $NEXT 函数
- linux系统(CentOS7)虚拟机上安装oracle 11g,解决oracle图形界面卡住无法点击next问题
- C++ Learning (Next)
- Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslis
- MySQL innodb 的间隙锁定(next-key locking)
- [CareerCup] 4.6 Find Next Node in a BST 寻找二叉搜索树中下一个节点
- Populating Next Right Pointers in Each Node II