結果

問題 No.2078 魔抜けなパープル
ユーザー lloyzlloyz
提出日時 2022-09-25 21:23:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 145 ms / 2,000 ms
コード長 262 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 87,276 KB
実行使用メモリ 76,220 KB
最終ジャッジ日時 2023-08-24 02:00:21
合計ジャッジ時間 1,863 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
75,864 KB
testcase_01 AC 120 ms
76,220 KB
testcase_02 AC 110 ms
76,036 KB
testcase_03 AC 117 ms
76,192 KB
testcase_04 AC 108 ms
76,076 KB
testcase_05 AC 108 ms
76,180 KB
testcase_06 AC 145 ms
76,180 KB
testcase_07 AC 110 ms
76,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(input())
INF = 10**18
for _ in range(t):
    x, a = map(int, input().split())
    ans = INF
    for cnt in range(1, a + 1):
        q, r = divmod(a, cnt)
        res = cnt * x + (cnt - r) * q**2 + r* (q + 1)**2
        ans = min(ans, res)
    print(ans)
0