LightOJ 1023 Discovering Permutations 水题

http://www.lightoj.com/volume_showproblem.php?problem=1023

题意:26字母全排列

思路:用next_permutation或者思维想一下都可以

/** @Date    : 2016-12-17-13.28
* @Author : Lweleth (SoungEarlf@gmail.com)
* @Link : https://github.com/
* @Version :
*/
#include<bits/stdc++.h>
#define LL long long
#define PII pair
#define MP(x, y) make_pair((x),(y))
#define fi first
#define se second
#define PB(x) push_back((x))
#define MMG(x) memset((x), -1,sizeof(x))
#define MMF(x) memset((x),0,sizeof(x))
#define MMI(x) memset((x), INF, sizeof(x))
using namespace std; const int INF = 0x3f3f3f3f;
const int N = 1e5+20;
const double eps = 1e-8; int main()
{
int T;
int cnt = 0;
cin >> T;
string s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
while(T--)
{
int n, m;
cin >> n >> m;
string t = s;
int ct = 0;
printf("Case %d:\n", ++cnt);
while(ct < m)
{
for(int i = 0; i < n; i++)
printf("%c", t[i]);
printf("\n");
ct++;
next_permutation(t.begin(), t.begin() + n);
if(t == s)
break;
}
}
return 0;
}
上一篇:20165312 2017-2018-2《Java程序设计》课程总结


下一篇:leetcode -- Permutations II TODO