https://www.codechef.com/problems/MUFFINS3

https://www.codechef.com/problems/MUFFINS3

In this program i dont understand what to do .can anyone explain me please?
it is mentioning in the question that max cupcake left, having two cupcake so we put 1 cupcake in package and one cupcake left over for chef to eat bt it is mention both cupcake in packet and no cupacke left for chef .

It’s mentioned that “Chef makes as many packages as possible of size A”. For two cupcakes, if the chef puts one cupcake in 1 package i.e. A=1, then he also puts the other cupcake in the second package leaving no leftover.

so for 5 cupcake why 2 left for chef to eat .we can put four cupcake each in four packet so left or we can put 2 cupacke each in one packet and 3 left cupcake …

I think you didn’t understand the problem. The requirement is to maximize the leftover by selecting appropriate package size. For 5 cupcakes, if the chef selects package size as 2, then 4 cupcakes would be put in two packages with one leftover. So the chef selects package size as 3, so there are 2 leftovers.

thanks @shashwat001 i got it

1 Like