821B.md (1652B)
1 Source: https://codeforces.com/problemset/problem/821/B 2 3 B. Okabe and Banana Trees 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees. 22 23 Consider the point (*x*, *y*) in the 2D plane such that *x* and *y* are integers and 0 ≤ *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 . 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. 24 25 Help Okabe and find the maximum number of bananas he can get if he chooses the rectangle wisely. 26 27 Okabe is sure that the answer does not exceed 1018. You can trust him. 28 29 Input 30 31 The first line of input contains two space-separated integers *m* and *b* (1 ≤ *m* ≤ 1000, 1 ≤ *b* ≤ 10000). 32 33 Output 34 35 Print the maximum number of bananas Okabe can get from the trees he cuts. 36 37 Examples 38 39 Input 40 41 ``` 42 1 5 43 ``` 44 45 Output 46 47 ``` 48 30 49 ``` 50 51 Input 52 53 ``` 54 2 3 55 ``` 56 57 Output 58 59 ``` 60 25 61 ``` 62 63 Note 64 65  66 67 The graph above corresponds to sample test 1. The optimal rectangle is shown in red and has 30 bananas.