POJ 3750 Child count problem data structure water

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.