No.2078 Clumsy Purple
タグ : / 解いたユーザー数 90
作問者 :
taiga0629kyopro
/ テスター :
Problem Statement
The hero taiga is trying to defeat $1$ monster. taiga's clumsiness is $X$, and his mp is $10^{100}$. The monster's combat power is $A$. Before fighting the monster, taiga can use the following magic 0 or more times.
- Choose an integer $k$ satisfying $1 \le k \le A$, and replace $A$ with $A-k$. Then, consume $k^2+X$ mp.
When taiga fights the monster, he can defeat it only if $A=0$; otherwise, he fails to defeat it and loses. Find the minimum mp consumed when he uses magic appropriately before the fight and defeats the monster.
You are given $T$ test cases; find the answer for each of them.
Constraints
Input
$T$
$\mathrm{case}_1$
$\mathrm{case}_2$
$\vdots$
$\mathrm{case}_T$
Each test case is given in the following format.
$X$ $A$
Output
Output $T$ lines. On the $i$-th line, output the answer for $\mathrm{case}_i$.
Sample
Sample 1
Input
3 3 3 6 29 100000 100000
Output
11 145 63245648
In the $1$-st test case, first use the magic with $k=2$, consuming $7$ mp, and then use the magic with $k=1$, consuming $4$ mp. A total of $11$ mp is consumed, $A=0$ holds, and the monster can be defeated. It is impossible to defeat the monster while consuming less mp than this.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。