question: Cards Game
There are M people from 1 to M . Andy has N cards with her. Starting with person Z , he gives the cards one by one to the people in the numbering order. Z, Z+1, Z+2,.....,M, 1, 2,....Z-1. Your task is to output the number of the person who will get the last card.
input 1:- 3 3 2
output 1:- 1
input 2 :- 1 100 1
output 2:- 1
m, n, z = input().split()
m = int(m) # number of peoples
n = int(n) # number of cards
z = int(z) # current person
current = z
while n > 1:
if current == m:
current = 1
else:
current += 1
n -= 1
print(current)
Comments
Leave a comment