結果

問題 No.2420 Simple Problem
ユーザー Nikkuniku029Nikkuniku029
提出日時 2023-08-12 18:07:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 341 ms / 2,000 ms
コード長 429 bytes
コンパイル時間 176 ms
コンパイル使用メモリ 82,452 KB
実行使用メモリ 101,792 KB
最終ジャッジ日時 2024-04-30 13:14:57
合計ジャッジ時間 12,370 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
52,468 KB
testcase_01 AC 171 ms
84,500 KB
testcase_02 AC 56 ms
68,080 KB
testcase_03 AC 111 ms
79,296 KB
testcase_04 AC 254 ms
95,528 KB
testcase_05 AC 185 ms
87,220 KB
testcase_06 AC 293 ms
101,524 KB
testcase_07 AC 290 ms
101,272 KB
testcase_08 AC 290 ms
101,556 KB
testcase_09 AC 287 ms
101,508 KB
testcase_10 AC 341 ms
101,548 KB
testcase_11 AC 297 ms
101,416 KB
testcase_12 AC 297 ms
101,404 KB
testcase_13 AC 295 ms
101,392 KB
testcase_14 AC 297 ms
101,416 KB
testcase_15 AC 292 ms
101,656 KB
testcase_16 AC 298 ms
101,520 KB
testcase_17 AC 293 ms
101,392 KB
testcase_18 AC 305 ms
101,320 KB
testcase_19 AC 293 ms
101,380 KB
testcase_20 AC 298 ms
101,388 KB
testcase_21 AC 300 ms
101,288 KB
testcase_22 AC 297 ms
101,776 KB
testcase_23 AC 301 ms
101,164 KB
testcase_24 AC 295 ms
101,792 KB
testcase_25 AC 296 ms
101,388 KB
testcase_26 AC 33 ms
53,080 KB
testcase_27 AC 265 ms
95,252 KB
testcase_28 AC 263 ms
95,404 KB
testcase_29 AC 246 ms
95,500 KB
testcase_30 AC 253 ms
95,508 KB
testcase_31 AC 280 ms
96,260 KB
testcase_32 AC 34 ms
52,572 KB
testcase_33 AC 168 ms
84,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(a, b):
    l = 1
    r = 64000
    P = 4*a*b
    while r-l > 1:
        mid = (l+r)//2
        Q = mid*mid - 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