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 KatrineYang at 2016-11-14 14:45:09 on Problem 1591
#include <stdio.h>
#include <string.h>


int N,X;

int main(int argc, char **argv){
	int sel = 0;
	//init();
	while(scanf("%d%d",&N,&X)>0){
		sel++;
		
		printf("Selection #%d\n", sel);
		int cards[20];
		for(int i = 0; i < 20; i++) scanf("%d",&cards[i]);
		int rem = N;
		int used[60] = {0};
		int cd = 0;
		int pos = 1;
		int cnt = 1;
		while(rem > X){
			int cyc = cards[cd];
			if(used[pos]){
				pos++;
				if(pos > N){
					pos = 1;
					cnt = 1;
					cd++;
					//continue;
				}
				//continue;
			}
			else if(cnt%cyc==0){
				used[pos] = 1;
				rem--;
				pos++;
				cnt++;
				if(pos > N){
					pos = 1; cnt = 1; cd++;
				}
			}
			else{
				pos++; cnt++;
				if(pos>N){pos=1, cnt=1, cd++;}
			}
		}
		int ccc = 0;
		for(int i = 1; i <= N; i++){
			if(!used[i]){
				printf("%d", i);
				ccc++;
				if(ccc!=X) printf(" ");
				else printf("\n\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