結果

問題 No.2420 Simple Problem
ユーザー noriocnorioc
提出日時 2023-08-12 16:57:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 683 ms / 2,000 ms
コード長 460 bytes
コンパイル時間 347 ms
コンパイル使用メモリ 82,424 KB
実行使用メモリ 76,584 KB
最終ジャッジ日時 2024-04-30 11:56:21
合計ジャッジ時間 21,617 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
53,096 KB
testcase_01 AC 314 ms
76,404 KB
testcase_02 AC 62 ms
73,928 KB
testcase_03 AC 152 ms
76,188 KB
testcase_04 AC 548 ms
76,400 KB
testcase_05 AC 358 ms
76,568 KB
testcase_06 AC 679 ms
76,412 KB
testcase_07 AC 683 ms
76,456 KB
testcase_08 AC 644 ms
76,180 KB
testcase_09 AC 641 ms
76,252 KB
testcase_10 AC 646 ms
76,412 KB
testcase_11 AC 653 ms
76,084 KB
testcase_12 AC 647 ms
76,452 KB
testcase_13 AC 675 ms
76,092 KB
testcase_14 AC 661 ms
76,028 KB
testcase_15 AC 642 ms
76,468 KB
testcase_16 AC 668 ms
76,172 KB
testcase_17 AC 661 ms
76,048 KB
testcase_18 AC 657 ms
76,368 KB
testcase_19 AC 644 ms
76,492 KB
testcase_20 AC 668 ms
76,040 KB
testcase_21 AC 644 ms
76,052 KB
testcase_22 AC 642 ms
76,048 KB
testcase_23 AC 653 ms
76,036 KB
testcase_24 AC 674 ms
76,300 KB
testcase_25 AC 677 ms
76,108 KB
testcase_26 AC 34 ms
53,280 KB
testcase_27 AC 524 ms
76,128 KB
testcase_28 AC 529 ms
76,252 KB
testcase_29 AC 513 ms
76,132 KB
testcase_30 AC 531 ms
76,172 KB
testcase_31 AC 521 ms
76,584 KB
testcase_32 AC 33 ms
52,680 KB
testcase_33 AC 293 ms
76,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def issatisfy(m, a, b) -> bool:
    s = m**2 - (a + b)
    if s <= 0: return False
    x = 4 * a * b
    y = s ** 2
    return x < y


# INF = 1 << 60
INF = 10 ** 5
N = int(input())
for _ in range(N):
    A, B = map(int, input().split())

    lo = 1
    hi = INF
    ans = INF
    while lo <= hi:
        m = (lo + hi) // 2
        if issatisfy(m, A, B):
            ans = min(ans, m)
            hi = m - 1
        else:
            lo = m + 1
    print(ans)
0