結果

問題 No.2078 魔抜けなパープル
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2022-09-25 22:56:15
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 525 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 87,040 KB
実行使用メモリ 95,652 KB
最終ジャッジ日時 2023-08-24 02:29:58
合計ジャッジ時間 4,812 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 158 ms
80,588 KB
testcase_01 AC 609 ms
89,868 KB
testcase_02 WA -
testcase_03 AC 538 ms
88,536 KB
testcase_04 AC 438 ms
86,504 KB
testcase_05 AC 444 ms
86,288 KB
testcase_06 AC 844 ms
95,652 KB
testcase_07 AC 304 ms
86,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline


def answer():
    X,A = map(int,input().split())
    L = math.floor(math.sqrt(X))
    INF =  (1<<30)
    dp = [INF]*(A+1)
    
    dp[0] = 0
    for i in range(1,A+1):
        if i<L-3:
            dp[i] = i**2 + X
            continue
        dp[i] = min(k**2 + X + dp[i-k] for k in range(max(1,L-5),min(i,L+5)+1))
    print(dp[A])
for _ in range(int(input())):
    answer()
    

    
0