問題一覧 > 通常問題

No.2078 Clumsy Purple

レベル : / AI推定難易度 : 1200 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 90
作問者 : taiga0629kyopro / テスター : ygussany hari64
お気に入りにしたユーザー ProblemId : 8502 / 自分の提出
問題文最終更新日: 2022-09-17 20:26:19
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 361 (順位表) の他の問題:

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

  • $1 \le T \le 20$
  • $0 \le X \le 10^5$
  • $1 \le A \le 10^5$
  • All input values are integers
  • 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もしくは右上の雲マークをクリックしてアカウントを作成してください。