Child count off problem
Time Limit: 1000MS |
|
Memory Limit: 65536K |
Total Submissions: 11739 |
|
Accepted: 5403 |
Description
There are n children in a circle, to them from the beginning of 1 numbered, is designated from the beginning of the first number of W, check the first S, the child out of the way, and then from the next child began to count, is still reporting s a out, so repeat, until all the children are out (the total number of less than s), the Order of
Input
Number of children entered in the first row N (n<=64)
Next, enter a child's name in each line (no more than 15 characters)
Last line Input w,s (W < N), with comma "," interval
Output
Output a child by person's name in the order in which they are ordered, each line outputs a name
Sample Input
5xiaomingxiaohuaxiaowangzhangsanlisi2,3
Sample Output
Zhangsanxiaohuaxiaomingxiaowanglisi
Source
Accode:
#include <iostream>using namespace Std;int main () { string name[65]; int loop,p[65]; for (int i=0;i<65;++i) p[i]=i; cin>>loop; int i=0; while (I<loop) cin>>name[i++]; int w,s; char c; cin>>w>>c>>s; w= (w+loop-1)%loop; do{ w= (w+s-1)%loop; cout<<name[p[w]]<< ' \12 '; for (int i=w;i<loop-1;++i) p[i]=p[i+1]; } while (--loop); return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
POJ 3750 Child count problem data structure water