Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
额,终于过了#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator