Bedmates


Submit solution

Points: 1
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
C, C++, Java, Python, Rust

Researchers have linked hospital roommate assignment with both positive and negative health outcomes. One particular point of contention is the number of roommates each patient should have. Too few can feel isolating, while too many can feel crowded and lack privacy.

Real roommate assignment depends on many factors, but Dr. Ian has proposed a simplified metric: the fellowship score. Distribute n patients into k non-empty rooms holding x_1, x_2, \dots, x_k patients (where \sum_{i=1}^{k} x_i = n). The fellowship score of the assignment is the product of the room sizes, F = \prod_{i=1}^{k} x_i.

You can use up to m rooms to split up the patients, but you don't need to use them all. Given this restruction, what is the maximum fellowship score that can be achieved with n patients?

Input

The first line contains two integers n and m (1 \leq n, m \leq 100), the number of patients to group into rooms and the number of rooms that are available.

Output

Output the maximum fellowship score that can be achieved by grouping the patients into rooms.

Example

Input 1
10 8
Output 1
36

Group the patients into 4 rooms, with 3, 3, 2 and 2 patients. The fellowship score is 3 \times 3 \times 2 \times 2, which is 36. It can be proven that no larger fellowship score is possible. Note that we only used 4 rooms here, but we could have used up to 8.

Input 2
10 2
Output 2
25
Input 3
27 6
Output 3
8000

Comments


  • 1
    Seng  commented on Sept. 19, 2026, 2:37 a.m.

    and they were roommates


    • 0
      frewmaster  commented on Sept. 19, 2026, 2:11 p.m.

      oh my god they were roommates