結果

問題 No.2078 魔抜けなパープル
ユーザー 👑 tamatotamato
提出日時 2022-09-25 21:04:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 419 bytes
コンパイル時間 277 ms
コンパイル使用メモリ 86,860 KB
実行使用メモリ 75,932 KB
最終ジャッジ日時 2023-08-24 01:53:10
合計ジャッジ時間 1,835 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
75,792 KB
testcase_01 AC 115 ms
75,748 KB
testcase_02 AC 106 ms
75,880 KB
testcase_03 AC 118 ms
75,932 KB
testcase_04 AC 105 ms
75,840 KB
testcase_05 AC 104 ms
75,900 KB
testcase_06 AC 138 ms
75,908 KB
testcase_07 AC 103 ms
75,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353


def main():
    import sys
    input = sys.stdin.readline

    for _ in range(int(input())):
        x, a = map(int, input().split())
        
        ans = float("inf")
        for i in range(1, a+1):
            b = a // i
            n1 = a % i
            n0 = i - n1
            ans = min(ans, (x + b ** 2) * n0 + (x + (b+1) ** 2) * n1)
        print(ans)


if __name__ == '__main__':
    main()
0