Cards Game
Write a program to print the following,
Input
The only line of input contains three space separated integers M,N and Z.
Output
Print the number representing the person who will get the last card.
Explanation
Given M=3, N=3, and Z=2.
Distribution of cards starts from 2.The final order of persons is 2,3,1.
The last person to get the card is 1.
Sample Input1
3 3 2
Sample Output1
1
M, K, Z = input("Enter M, K and Z respectively separated by SPACE: ").split()
M = int(M)
K = int(K)
Z = int(Z)
while(K > 1):
Z += 1
if Z > M:
Z = 1
K = K-1
print(Z)
Comments
Leave a comment