Junyeong
Time limit1sMemory limit1024 MB
Given an N by M chocolate bar, split it into rectangles with straight cuts to maximize the product of piece areas, modulo 1e9+7.
- Level
Medium6 of 10
- Topics
- Dynamic programming, Math
- Solved
- No attempts yet
Problem

Junyeong breaks up the chocolate bars he has so he can share them with friends who are preparing for a sports day.
At the start, Junyeong has one chocolate piece shaped like a rectangle with width and height . He may pick one piece and split it into 2 smaller pieces, repeating this 0 or more times. When all splits are finished, every piece must be a rectangle, and each side length must be an integer.
As the proverb says, sharing doubles the joy. The total joy Junyeong gets is the product of the sizes of the remaining pieces after all splits are finished. A piece with width and height has size .
Find the maximum joy Junyeong can get.
Input
The first line contains two integers and , separated by a space.
Output
Print the maximum joy Junyeong can get from splitting the chocolate, modulo .