結果

問題 No.2420 Simple Problem
ユーザー Nikkuniku029Nikkuniku029
提出日時 2023-08-12 14:31:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 322 ms / 2,000 ms
コード長 428 bytes
コンパイル時間 182 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 101,788 KB
最終ジャッジ日時 2024-04-30 06:22:14
合計ジャッジ時間 12,222 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
52,096 KB
testcase_01 AC 170 ms
84,376 KB
testcase_02 AC 54 ms
67,328 KB
testcase_03 AC 105 ms
79,620 KB
testcase_04 AC 259 ms
95,900 KB
testcase_05 AC 192 ms
87,232 KB
testcase_06 AC 295 ms
101,300 KB
testcase_07 AC 293 ms
101,120 KB
testcase_08 AC 311 ms
101,256 KB
testcase_09 AC 297 ms
101,256 KB
testcase_10 AC 309 ms
101,512 KB
testcase_11 AC 296 ms
101,120 KB
testcase_12 AC 300 ms
101,516 KB
testcase_13 AC 302 ms
101,268 KB
testcase_14 AC 306 ms
101,240 KB
testcase_15 AC 322 ms
101,524 KB
testcase_16 AC 308 ms
101,788 KB
testcase_17 AC 315 ms
101,260 KB
testcase_18 AC 305 ms
101,300 KB
testcase_19 AC 305 ms
101,492 KB
testcase_20 AC 303 ms
101,280 KB
testcase_21 AC 296 ms
101,152 KB
testcase_22 AC 304 ms
101,648 KB
testcase_23 AC 296 ms
101,252 KB
testcase_24 AC 299 ms
101,004 KB
testcase_25 AC 300 ms
101,400 KB
testcase_26 AC 33 ms
52,608 KB
testcase_27 AC 254 ms
95,380 KB
testcase_28 AC 252 ms
95,688 KB
testcase_29 AC 265 ms
95,760 KB
testcase_30 AC 273 ms
96,000 KB
testcase_31 AC 291 ms
96,268 KB
testcase_32 AC 31 ms
51,968 KB
testcase_33 AC 167 ms
84,116 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(a, b):
    l = 1
    r = 64000
    P = 4*a*b
    while r-l > 1:
        mid = (l+r)//2
        Q = mid**2 - a - b
        R = Q**2
        if Q > 0:
            if P < R:
                r = mid
            else:
                l = mid
        else:
            l = mid
    return r


N = int(input())
ans = []
for _ in range(N):
    A, B = map(int, input().split())
    ans.append(solve(A, B))
print(*ans, sep="\n")
0