HDU 1027 Ignatius and the Princess II

来源:互联网 发布:电信网络电视多少钱 编辑:程序博客网 时间:2024/05/16 01:56

全排列,next_permutation


#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <math.h>#include <vector>using namespace std;#define sf scanf#define pf printf#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)#define dbg(x) cerr << "Line:" <<  __LINE__ << " : " << #x << " = " << (x) << endl#define nMax 1000000#define ll long long#define CLR(a) memset((a),0,sizeof((a)))int n,m;int main() {#ifndef ONLINE_JUDGEfreopen("in.txt","r",stdin);#endifwhile(sf("%d%d",&n,&m)==2) {vector<int> a(n);rep(i,n) a[i]=i+1;rep(i,m-1) next_permutation(a.begin(),a.end());rep(i,n) {if(i) pf(" ");pf("%d",a[i]);}pf("\n");}return 0;}


原创粉丝点击