Limits 1s, 512 MB

Mrs SSM always gives assignments to her students. Last week was no different, as she gave an assignment as usual. The task was given a number N, the students have to find M elements in such a way so that their sum is equal to N.

All the students except Tahsin submitted their assignments. Tahsin suddenly noticed that if he does not get the assignment’s marks then he will fail in the exam. So he asked Mrs SSM for extension of the deadline. Although initially she was angry at Tahsin, she nonetheless agreed to extend the deadline.

But the condition is: she will add some more tasks with the assignment to make it more difficult, as Tahsin can copy the assignment from the students who have already done it.

Tahsin agreed to the condition put forth by Mrs SSM. The new task is given a number N, Tahsin has to pick M elements in such a way so that their sum is equal to N and their product is also the maximum possible.

Now Tahsin doesn’t know the answer. You are the best friend of Tahsin, and he came to you, pleading to help him out. Can you help him by finding maximal product?


Input will consists of only two integers N and M. ( 1 <= M <= 20 , M <= N <= 100 )


In a single line, print the maximum product.


10 3

All the inputs are valid and answer exists.


Login to submit.


71% Solution Ratio
dip_BRUREarliest, Feb '18
hredhayxzFastest, 0.0s
hredhayxzLightest, 0 B
Nusab19Shortest, 66B
Toph uses cookies. By continuing you agree to our Cookie Policy.