×

# ACM14KG2 - Editorial

Author: Anudeep Nekkanti
Tester: Mahbubul Hasan
Editorialist: Jingbo Shang

Cakewalk

# PREREQUISITES:

Basic Programming

# PROBLEM:

There are N people in a circle. And a ball is passing clockwise starting from the a-th person (index is 1-based). Asking for the index of the person with the ball after M passes.

# EXPLANATION:

If the index is 0-based, the answer could be easily get using the mod operations. Therefore, we first transform the number to 0-based, i.e. a-th person is (a-1) in 0-based.

Then, the answer in 0-based should be (a-1+M)%N.

Finally, the answer in 1-based is (a-1+M)%N+1.

# AUTHOR'S AND TESTER'S SOLUTIONS:

Solutions will be available soon.

Author's solution can be found here.
Tester's solution can be found here.

This question is marked "community wiki".

161446375
accept rate: 0%

19.7k350498541

 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×15,492
×1,610
×931
×13
×5

question asked: 01 Dec '14, 09:11

question was seen: 984 times

last updated: 18 Mar '15, 17:26