Answer to Question #290253 in Python for Bubby

Question #290253

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 Input 1:

3 3 2

Sample Output 1:

1

Sample Input 2:

1 100 1

Sample Output 2:

1


1
Expert's answer
2022-01-24T11:09:07-0500
n, k, a = input().split()
n, k, a = int(n), int(k), int(a)


while k > 1:
	a += 1
	if a > n:
		a = 1
	k -= 1


print(a)

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