Computer Science, asked by manjusha23091995, 11 months ago

You are teacher in reputed school. During celebration day you were assigned a task to distribute cadburay such that maximum children get the chocolate. You have a box full of cadburay with different weight and height. You can distribute only last square shape cadburay. So if you have a cadburay of length 10 and width 5, then you need then you need break cadburay in 5x5 square and distribute to first child and remaining 5x5 to next child

Answers

Answered by aman81930
2
Sorry I can’t understand your question
Answered by sayanchatto
21

m, n, p, q = raw_input().split(":")

ll = int

bb = int

count = 0

def cadbury(m, n, p, q):

   leng = [m, n]

   brd = [p, q]

   for l in leng:

       for b in brd:

           call(l, b)

def call(l, b):

   #print l,b

   global count

   area = l * b

   if l > b:

       bb = l

       rem = bb - b

       #print rem

       rem_part1 = rem

       #print rem_part1

       rem_part2 = b

       #print rem_part2

       l = rem_part1

       #print l

       b = rem_part2

       #print b

       if l != b:

           if (l==1) or (b==1):

               count += 1

               count += (l*b)

               #print count

               return

           else:

               count += 1

               #print count

               call(l, b)

       if l==b:

           count+=2

           #print count

           return

   elif b > l:

       ll = b

       #print ll

       rem = ll - l

       #print rem

       rem_part1 = rem

       #print rem_part1

       rem_part2 = l

       #print rem_part2

       l = rem_part1

       #print l

       b = rem_part2

       #print b

       if l != b:

           if (l==1) or (b==1):

               count += 1

               count += (l*b)

               #print count

               return

           else:

               count += 1

               #print count

               call(l, b)

       if l==b:

           count+=2

           #print count

           return

cadbury(int(m), int(n), int(p), int(q))

print count

Similar questions