You are a teacher in reputed school. During Celebration Day you were assigned a task to distribute Cadbury such that maximum children get the chocolate. You have a box full of Cadbury with different width and height. You can only distribute largest square shape Cadbury. So if you have a Cadbury of length 10 and width 5, then you need to break Cadbury in 5X5 square and distribute to first child and then remaining 5X5 to next in queue
Answers
Answered by
2
Answer:
p=int(input())
q=int(input())
r=int(input())
s=int(input())
c=0
def child_count(i,j):
count=0
while(i!=0 and j!=0):
count+=1
if(i>j):
i-=j
else:
j-=i
return count
for i in range(p,q+1):
for j in range(r,s+1):
c+=child_count(i,j)
print(c)
Explanation:
Answered by
0
Answer:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
count=0
for i in range(a,b+1):
for j in range(c,d+1):
larger=max(i,j)
minimum=min(i,j)
while minimum>=1 and larger>=1:
larger-=minimum
count+=1
print(count)
Explanation: Try this :)
Similar questions