Answer to Question #302773 in Python for Lokesh

Question #302773

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



1
Expert's answer
2022-03-02T03:04:44-0500
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)

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