Poj 3750 data report (Joseph's problem)

Source: Internet
Author: User
Data Report for children
Time limit:1000 ms   Memory limit:65536 K
Total submissions:9883   Accepted:4597

Description

There are n Children in a circle and number them in sequence from 1. Now the number is specified to start from W. When the number is reported to S, the child is listed, next, report the number from the next child, and report the number of S columns. Repeat this until all the children are listed (if the total number is less than S, report the number cyclically.

Input

Number of children in the first line n (n <= 64)
Next, enter the name of a child in each line (the name cannot exceed 15 characters)
Enter W, S (W <n) in the last line, and separate them with commas (,).

Output

Output by person name the children are listed in order, and each row outputs a person's name

Sample Input

5XiaomingXiaohuaXiaowangZhangsanLisi2,3

Sample output

ZhangsanXiaohuaXiaomingXiaowangLisi

Source

This is an entry-level question of Joseph's question. It is an application of linear tables,

However, the compile error is reported several times in poj today;

The idea is to output the name after reporting the number to this position, and then move the subsequent sequence number one by one;

# Include <cstdio> # include <cstring> # include <iostream> using namespace STD; int main () {string name [65]; // storage name int N, W, s, index [65]; scanf ("% d", & N); For (INT I = 0; I <n; I ++) {CIN> name [I]; index [I] = I; // store the serial number of each child's location} scanf ("% d", & W, & S); W = (W + N-1) % N; // do {W = (W + s-1) % N; cout <name [index [w] <Endl; For (INT I = W; I <n-1; I ++) // move the following element forward to an index [I] = index [I + 1];} while (-- N); Return 0 ;}



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.