CF1978B.New Bakery

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

New Bakery

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

  • Bob chooses some integer kk (0kmin(n,b)0 \le k \le \min(n, b)).
  • Bob sells the first kk buns at a modified price. In this case, the price of the ii-th (1ik1 \le i \le k) sold bun is (bi+1)(b - i + 1) coins.
  • The remaining (nk)(n - k) buns are sold at aa coins each.

Note that kk can be equal to 00. In this case, Bob will sell all the buns at aa coins each.

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

Input

Each test consists of multiple test cases. The first line contains a single integer tt (1t1041 \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 nn, aa, and bb (1n,a,b1091 \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=1k = 1. Then he will sell one bun for 55 coins, and three buns at the usual price for 44 coins each. Then the profit will be 5+4+4+4=175 + 4 + 4 + 4 = 17 coins.

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

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

Samples

7
4 4 5
5 5 9
10 10 5
5 5 11
1000000000 1000000000 1000000000
1000000000 1000000000 1
1000 1 1000
17
35
100
45
1000000000000000000
1000000000000000000
500500

在线编程 IDE

建议全屏模式获得最佳体验