結果

問題 No.2078 魔抜けなパープル
ユーザー terasaterasa
提出日時 2022-09-28 19:09:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 179 ms / 2,000 ms
コード長 701 bytes
コンパイル時間 269 ms
コンパイル使用メモリ 87,300 KB
実行使用メモリ 77,828 KB
最終ジャッジ日時 2023-08-24 04:33:11
合計ジャッジ時間 2,742 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
77,416 KB
testcase_01 AC 158 ms
77,520 KB
testcase_02 AC 147 ms
77,788 KB
testcase_03 AC 154 ms
77,516 KB
testcase_04 AC 145 ms
77,444 KB
testcase_05 AC 147 ms
77,828 KB
testcase_06 AC 179 ms
77,656 KB
testcase_07 AC 145 ms
77,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
import sys
import pypyjit
import itertools
import heapq
import math
from collections import deque, defaultdict
from functools import lru_cache

# for AtCoder Easy test
if __file__ == 'prog.py':
    pass
else:
    sys.setrecursionlimit(10 ** 6)
pypyjit.set_param('max_unroll_recursion=-1')

input = sys.stdin.readline


def readints(): return map(int, input().split())
def readlist(): return list(readints())
def readstr(): return input()[:-1]


T = int(input())
for _ in range(T):
    X, A = readints()
    ans = float('inf')
    for i in range(1, A + 1):
        p, q = divmod(A, i)
        ans = min(ans, p * p * (i - q) + (p + 1) * (p + 1) * q + X * i)
    print(ans)
0