1742.Okabe and Banana Trees

Time Limit: 1s Memory Limit: 256MB

Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees.Consider the point (x,y) in the 2D plane such that x and y are integers and 0 \le x,y. There is a tree in such a point, and it has x+y bananas. There are no trees nor bananas in other points. Now, Okabe draws a line with equation 1742_1.png. Okabe can select a single rectangle with axis aligned sides with all points on or under the line and cut all the trees in all points that are inside or on the border of this rectangle and take their bananas. Okabe's rectangle can be degenerate; that is, it can be a line segment or even a point.Help Okabe and find the maximum number of bananas he can get if he chooses the rectangle wisely.Okabe is sure that the answer does not exceed 1018. You can trust him.

Input Format(From the terminal/stdin)

Input The first line of input contains two space-separated integers m and b (1 \le m \le 1000, 1 \le b \le 10000).

Output Format(To the terminal/stdout)

Output Print the maximum number of bananas Okabe can get from the trees he cuts.

Sample Input 1

Copy
1 5
 · \n

Sample Output 1

Copy
30
  \n

Sample Input 2

Copy
2 3
 · \n

Sample Output 2

Copy
25
  \n

Hints

1742_2.png The graph above corresponds to sample test 1. The optimal rectangle is shown in red and has 30 bananas.

Submit

请先 登录

© 2025 FAQs