Answer to Question #316953 in Python for Manish

Question #316953

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


1
Expert's answer
2022-03-25T04:36:32-0400
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)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS