首页 技术 正文
技术 2022年11月7日
0 收藏 472 点赞 963 浏览 730 个字

366-D的小L

内存限制:64MB
时间限制:4000ms
特判: No

通过数:5
提交数:7
难度:2

题目描述:

      一天TC的匡匡找ACM的小L玩三国杀,但是这会小L忙着哩,不想和匡匡玩但又怕匡匡生气,这时小L给匡匡出了个题目想难倒匡匡(小L很D吧nyoj  366-D的小L (next_permutation())),有一个数n(0<n<10),写出1到n的全排列,这时匡匡有点囧了nyoj  366-D的小L (next_permutation()),,,聪明的你能帮匡匡解围吗?

输入描述:

第一行输入一个数N(0<N<10),表示有N组测试数据。后面的N行输入多组输入数据,每组输入数据都是一个整数x(0<x<10)

输出描述:

按特定顺序输出所有组合。
特定顺序:每一个组合中的值从小到大排列,组合之间按字典序排列。

样例输入:

复制

2
2
3

样例输出:

12
21
123
132
213
231
312
321

C/C++  AC:

 #include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#include <queue>
#include <climits>
#define PI 3.1415926 using namespace std;
const int MY_MAX = ;
int N, m[MY_MAX]; int main()
{
cin >>N;
while (N --)
{
int temp, A[];
cin >>temp;
for (int i = ; i < temp; ++ i)
{
A[i] = i + ;
} do
{
for (int i = ; i < temp; ++ i)
printf("%d", A[i]);
printf("\n");
} while(next_permutation(A, A+temp));
}
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,487
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,903
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,736
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,487
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,127
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,289