You are not logged in. Please login at www.codechef.com to post your questions!

×

ACM14KG2 - Editorial

PROBLEM LINK:

Practice
Contest

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

DIFFICULTY:

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".

asked 01 Dec '14, 09:11

shangjingbo's gravatar image

3★shangjingbo ♦♦
161446173
accept rate: 0%

edited 18 Mar '15, 17:26

admin's gravatar image

0★admin ♦♦
18.5k348495529

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • 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:

×14,072
×1,369
×851
×13
×5

question asked: 01 Dec '14, 09:11

question was seen: 859 times

last updated: 18 Mar '15, 17:26