結果

問題 No.2420 Simple Problem
ユーザー ThetaTheta
提出日時 2024-03-06 18:37:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 653 bytes
コンパイル時間 261 ms
コンパイル使用メモリ 11,776 KB
実行使用メモリ 16,788 KB
最終ジャッジ日時 2024-03-06 18:38:41
合計ジャッジ時間 35,833 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,112 KB
testcase_01 AC 955 ms
10,112 KB
testcase_02 AC 36 ms
10,112 KB
testcase_03 AC 357 ms
10,112 KB
testcase_04 AC 1,823 ms
10,112 KB
testcase_05 AC 1,162 ms
10,112 KB
testcase_06 TLE -
testcase_07 TLE -
testcase_08 TLE -
testcase_09 TLE -
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 AC 29 ms
10,112 KB
testcase_27 AC 1,771 ms
10,112 KB
testcase_28 AC 1,790 ms
10,112 KB
testcase_29 AC 1,757 ms
10,112 KB
testcase_30 AC 1,763 ms
10,112 KB
testcase_31 AC 1,770 ms
10,112 KB
testcase_32 AC 30 ms
10,112 KB
testcase_33 AC 970 ms
10,112 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