Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

表示这东西是个环。。。

Posted by Sigma_Poet at 2015-08-02 21:21:12 on Problem 1833
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>

using namespace std;

int T;
int a[1025];

int main(){
	scanf("%d",&T);
	while(T --){
		int N,K;
		scanf("%d%d",&N,&K);
		for(int i = 1;i <= N;++ i)
		    scanf("%d",&a[i]);
		
		for(int i = 1;i <= K;++ i){
			if(next_permutation(a+1,a+N+1)){
				continue;
			}
			else{
				for(int i = 1;i <= N;++ i)
				a[i] = i;
			}
		}
		
		for(int i = 1;i <= N;++ i)
		    printf("%d ",a[i]);
		printf("\n");
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator