Computer Science, asked by rajputshreya272, 7 months ago

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
Constraints
O<P<Q<1501
O<R<S< 1501
Input Format
First line contains an integer P that denotes minimum length of Cadbury in the box
Second line contains an integer Q that denotes maximum length of Cadbury in the box
Third line contains an integer R that denotes minimum width of Cadbury in the box
Fourth line contains an integer Sthat denotes maximum width of Cadbury in the box
Output
Print total number of children who will get chocolate.
Timeout
- Explanation
Example 1
input
5
7
3
4

output
24

Answers

Answered by sharipriya311099
1

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:

Similar questions