跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F0712. Okabe and Banana Trees

  • ID: 718
  • 传统题
  • 2000ms
  • 256MiB
  • 尝试: 0
  • AC · 已通过: 0
  • 教学难度:基础
  • 上传者:
  • 枚举
  • 数学
  • 算法思想
  • 基础
  • 难度
  • 共享题库
  • Codeforces
  • 英文题面
  • 题目来源
  • 题面语言

Okabe and Banana Trees

题目描述

B. Okabe and Banana Trees
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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≤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.

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

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

Output

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

Examples
Input
1 5
Output
30
Input
2 3
Output
25
Note

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


题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 127 题。保留原作者与原赛事署名。