Codeforces Round 953 (Div. 2)
B
New Bakery
Codeforces
800
原题
← AC →
翻译中…

Bob decided to open a bakery. On the opening day, he baked $n$ buns that he can sell. The usual price of a bun is $a$ coins, but to attract customers, Bob organized the following promotion:

翻译中…
  • Bob chooses some integer $k$ ($0 \le k \le \min(n, b)$).
  • Bob sells the first $k$ buns at a modified price. In this case, the price of the $i$-th ($1 \le i \le k$) sold bun is $(b - i + 1)$ coins.
  • The remaining $(n - k)$ buns are sold at $a$ coins each.
翻译中…

Note that $k$ can be equal to $0$. In this case, Bob will sell all the buns at $a$ coins each.

翻译中…

Help Bob determine the maximum profit he can obtain by selling all $n$ buns.

翻译中…

Input

翻译中…

Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \le t \le 10^4$) — the number of test cases. The description of the test cases follows.

翻译中…

The only line of each test case contains three integers $n$, $a$, and $b$ ($1 \le n, a, b \le 10^9$) — the number of buns, the usual price of a bun, and the price of the first bun to be sold at a modified price.

翻译中…

Output

翻译中…

For each test case, output a single integer — the maximum profit that Bob can obtain.

翻译中…

Note

翻译中…

In the first test case, it is optimal for Bob to choose $k = 1$. Then he will sell one bun for $5$ coins, and three buns at the usual price for $4$ coins each. Then the profit will be $5 + 4 + 4 + 4 = 17$ coins.

翻译中…

In the second test case, it is optimal for Bob to choose $k = 5$. Then he will sell all the buns at the modified price and obtain a profit of $9 + 8 + 7 + 6 + 5 = 35$ coins.

翻译中…

In the third test case, it is optimal for Bob to choose $k = 0$. Then he will sell all the buns at the usual price and obtain a profit of $10 \cdot 10 = 100$ coins.

翻译中…

样例

Input #1
7
4 4 5
5 5 9
10 10 5
5 5 11
1000000000 1000000000 1000000000
1000000000 1000000000 1
1000 1 1000
Output #1
17
35
100
45
1000000000000000000
1000000000000000000
500500
InputCopy OutputCopy
题目信息
题号
1978B
时间限制
1 s
内存限制
256 MB
标签
二分
贪心
数学
三分

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。