結果

問題 No.2078 魔抜けなパープル
ユーザー titiatitia
提出日時 2022-09-25 22:02:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 341 bytes
コンパイル時間 528 ms
コンパイル使用メモリ 10,708 KB
実行使用メモリ 7,948 KB
最終ジャッジ日時 2023-08-24 02:13:38
合計ジャッジ時間 9,946 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
7,736 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 TLE -
testcase_07 AC 967 ms
7,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T=int(input())
for tests in range(T):
    X,A=map(int,input().split())

    ANS=A*(1*1+X)

    r=A//2
    rest=A-r*2

    ANS2=r*(2*2+X)+rest*(1*1+X)

    ANS=min(ANS,ANS2)

    for i in range(2,A+1):
        r=A//i
        rest=A-r*i

        ANS2=(r-rest)*(i*i+X)+rest*((i+1)*(i+1)+X)

        ANS=min(ANS,ANS2)


    print(ANS)

        
0