PROBLEM LINK:Author: Anudeep Nekkanti DIFFICULTY:Cakewalk PREREQUISITES:Basic Programming PROBLEM:There are N people in a circle. And a ball is passing clockwise starting from the ath person (index is 1based). Asking for the index of the person with the ball after M passes. EXPLANATION:If the index is 0based, the answer could be easily get using the mod operations. Therefore, we first transform the number to 0based, i.e. ath person is (a1) in 0based. Then, the answer in 0based should be (a1+M)%N. Finally, the answer in 1based is (a1+M)%N+1. AUTHOR'S AND TESTER'S SOLUTIONS:Solutions will be available soon. Author's solution can be found here.
This question is marked "community wiki".
asked 01 Dec '14, 09:11
