結果

問題 No.2420 Simple Problem
ユーザー ThetaTheta
提出日時 2024-03-06 18:57:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 640 ms / 2,000 ms
コード長 653 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 76,500 KB
最終ジャッジ日時 2024-03-06 18:57:39
合計ジャッジ時間 21,531 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
53,588 KB
testcase_01 AC 304 ms
76,500 KB
testcase_02 AC 60 ms
69,716 KB
testcase_03 AC 144 ms
76,500 KB
testcase_04 AC 503 ms
76,500 KB
testcase_05 AC 341 ms
76,500 KB
testcase_06 AC 634 ms
76,500 KB
testcase_07 AC 633 ms
76,500 KB
testcase_08 AC 606 ms
76,500 KB
testcase_09 AC 640 ms
76,500 KB
testcase_10 AC 610 ms
76,500 KB
testcase_11 AC 640 ms
76,500 KB
testcase_12 AC 612 ms
76,500 KB
testcase_13 AC 634 ms
76,500 KB
testcase_14 AC 611 ms
76,500 KB
testcase_15 AC 635 ms
76,500 KB
testcase_16 AC 615 ms
76,500 KB
testcase_17 AC 615 ms
76,500 KB
testcase_18 AC 633 ms
76,500 KB
testcase_19 AC 607 ms
76,500 KB
testcase_20 AC 638 ms
76,500 KB
testcase_21 AC 608 ms
76,500 KB
testcase_22 AC 632 ms
76,500 KB
testcase_23 AC 610 ms
76,500 KB
testcase_24 AC 632 ms
76,500 KB
testcase_25 AC 610 ms
76,500 KB
testcase_26 AC 35 ms
53,588 KB
testcase_27 AC 534 ms
76,148 KB
testcase_28 AC 512 ms
76,148 KB
testcase_29 AC 532 ms
76,148 KB
testcase_30 AC 509 ms
76,148 KB
testcase_31 AC 523 ms
76,500 KB
testcase_32 AC 34 ms
53,588 KB
testcase_33 AC 281 ms
76,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import count
from math import sqrt
import sys


def printe(*args, end="\n", **kwargs):
    print(*args, end=end, file=sys.stderr, **kwargs)


def main():
    N = int(input())
    for _ in range(N):
        A, B = map(int, input().split())
        X_floor = sqrt(A) + sqrt(B)

        for num in count(int(X_floor - 3)):
            if num < 1:
                continue
            if num**2 - A - B <= 0:
                continue
            if 4 * A * B < (num**2 - A - B)**2:
                print(num)
                break

    # A+B+2√AB < X^2
    # 2√AB < X^2-A-B
    # 4AB < (X^2-A-B)^2


if __name__ == "__main__":
    main()
0