Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What a splendid day! Your TA has brought cake for the class session, and since it sounds too good to be true there is obviously

What a splendid day! Your TA has brought cake for the class session, and since it sounds too good to be true there is obviously a catch. There are only KK pieces of cake and the TA wants to test her students mathematical foresight, so she has set up a devious game, where only KK students will get some cake.

The game goes as follows: All NN students in the class stand in a circle, where the students are numbered 1 through NN. We use a counting threshold CC in order to know when to remove a student from the circle. Counting starts from student 1, and then we go to student 2, et cetera. We keep counting until the counter reaches CC, and we remove that person from the circle. Then the counter is reset and starts at 1 at the student right next to the one who was just removed. The TA keeps doing this until there are only KK students left in the circle, and then the game stops, and those not removed will get the cake.

You and your, coincidentally, K-1K1 friends really want the cake, but you need to figure out where in the circle you and your friends need to stand in order to not get removed. Maybe a simple computer program can assist you?

Input format

  • 1 line with 3 space separated integers: NN, CC, KK, which are respectively the number of students in the class, the counter threshold, and the number of friends in your class. It holds that 1\leq C \leq 10^91C109 and 1 \leq K\leq N \leq 10001KN1000.

Output format

  • a space separated list of KK integers, indicating the placement of you and your friends in the circle in order for you all to get the cake. It has to be sorted in increasing order (1-indexed).

image text in transcribed

Input 1 11 2 3 Output 1 3 7 11 Input 1 11 2 3 Output 1 3 7 11

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions