Game
There are N people in a party numbered 1 to N. Sruthi has K cards with her. Starting with person A, she gives the cards one by one to the people in the party in the numbering order: A, A+1, A+2, . .., N, 1, 2,..., A-1. Your task is to output the number of the person who will get the last card.
Input
The only line of input contains space separated integers N, K and A.
Output
print the number representing the person who will get the last card.
Explanation
Given N=3, K=3 and A=2.
Distribution of cards starts from 2. The final order of person is 2,3,1.
The last person to get the card is 1.
Sample Input1
3 3 2
Sample Output1
1
Sample Input 2
1 100 1
Sample Output2
1
N = int(input("number of people >> "))
K = int(input("number of card >> "))
A = int(input("start from >> "))
num = A - 1
for i in range(K):
num += 1
if(num > N):
num = 1
print(num)
Comments
Leave a comment