Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
15 views

Python Problem Tom Chees

The document describes a function to calculate the maximum number of blocks Tom can use to reach Jerry given the total number of blocks, number of blocks Jerry has already used, and number of ways Tom can use the blocks.

Uploaded by

Madhu Painkiller
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Python Problem Tom Chees

The document describes a function to calculate the maximum number of blocks Tom can use to reach Jerry given the total number of blocks, number of blocks Jerry has already used, and number of ways Tom can use the blocks.

Uploaded by

Madhu Painkiller
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

-----------------------------------------------------no of ways to tom to reach

jerry with blocks

def winner(n,m,k):
if n==m or m==0:
return 0
ncp=n/k
l=[]
j=0
if m>ncp:
l[j]=ncp
m=m-ncp
for z in range(1,k):
if z!=k-1 and m>0:
l[z]=1
m=m-1
if z==k-1 and m>0:
l[z]=m
if m==0:
l[z]=0

return max(l)

op=[]
q=int(input())
for i in range(q):
n,m,k=map(int,input().split())
op[i]=winner(n,m,k)
for i in op:
print(i)

You might also like