Seven questions to ask Joseph # 2019120700020

1. Basic Joseph problems

Title Description

\ (n-\) Personal ( \ (n-\ Le 100 \) ) circle, beginning from the first individual packet count, count \ (m \) of the person column, and then again from the next person \ (1 \) began to count off the number to \ (m \) people and then a circle, ...... and so on, until everyone turns out, please turn out the circle of people in the output number.

Input Format

\(n m\)

Output Format

A circle of numbers

Sample input

10 3

Sample Output

3 6 9 2 7 1 8 5 10 4

Explanation

\ (M, n \ 100 \)

2

Description of the meaning of problems

It is known n individuals (with numbers 1,2,3 ... n, respectively) were sitting around a round table. From the number of people gettin k number, that person's number to the m column; his next person and from 1 Countin, that person has a number of columns to m; and so the law is repeated until around round table were all out of the line.

Entry

\(n,k,m\)

Export

Sequentially output a circle of people numbering

Sample input

9 1 5

Sample Output

5 1 7 4 3 6 9 2 8

3

Joseph problem is a famous problem: \ (N \) personal circle, beginning from the first number reported, the first \ (M \) number will be killed, the last remaining one, the rest will be killed . For example, \ (N =. 6 \) , \ (. 5 M = \) , the number of people killed 5,4,6,2,3. The last remaining No. 1.
Before assuming that in circles \ (K \) one is a good man, after \ (K \) months for the bad guys, so your task is to determine the minimum \ (M \) , so that all the bad guys before the first killed a good man out.

4

n personal arranged in a circle. From the beginning of a person, in a clockwise direction are numbered. From the number of people 1 clockwise in "December First" reported the number of people who quit report 2 circles. So continue the cycle continues, the circle of people will continue to decrease. Since the number of people is limited, so eventually the rest of a person. How can the last remaining person beginning number.

Entry

A positive integer \ (n-\) , represents the number of people. N ensure that the digital input data does not exceed 100.

Export

A positive integer. After that represents "one two one" number reported last remaining human numbers.

Sample input

9

Sample Output

3

5

There are 10 holes around the top of the hill, foxes eat the rabbit, the rabbit said: "Yes, but must find me, I'll hide in the cave ten, you start from the 10th hole, first hole to find a No. 1, second once every 1 to find a hole, third every two holes to find, after so forth, unlimited. "but the fox from morning to night and out of the 1000, still did not find the rabbit. Q. Which rabbit is hiding in the cave?

6

Numbered 1,2, ...., \ (N \) a \ (N \) personal clockwise around a circle, each holding a password (positive integer). Optionally a positive integer outset as a limit on the number of newspaper \ (M \) , from the first person to start moving clockwise from the start sequence number 1 newspaper, reported that the number of stops at registration M. M reported a man out of the line, his password as the new \ (M \) values, starting with his next person in a clockwise direction again from number 1 newspaper, and so on, until all the columns up to everyone. try to design a program to find out the order of the columns.

Test Data

\ (N =. 7 \) ;
. 7 personal password as follows: 3,1,7,2,4,8,4, firstly \ (M \) value of 6 (the correct sequence should be dequeued 6,1, 4,7,2,3,5)

7

There x race cars, numbered 1,2,3,4 on a circular track, ......, \ (the X-\) , each experiencing a circle, the first will be reduced to second place, second place will be reduced to third place, third place will be reduced to the fourth, and so on, the last one was promoted to the first, and will be eliminated in the third row of riders.
If each out of his output to a number that corresponds to only the last rider eliminated, the required output this number set.

Guess you like

Origin www.cnblogs.com/liuziwen0224/p/12000520.html