結果

問題 No.2420 Simple Problem
ユーザー Kyoro IDKyoro ID
提出日時 2023-08-12 15:23:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 735 bytes
コンパイル時間 325 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 45,440 KB
最終ジャッジ日時 2024-04-30 09:08:53
合計ジャッジ時間 30,395 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
12,032 KB
testcase_01 WA -
testcase_02 AC 50 ms
12,160 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 524 ms
28,800 KB
testcase_06 WA -
testcase_07 AC 987 ms
45,312 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 993 ms
45,440 KB
testcase_14 WA -
testcase_15 AC 987 ms
45,312 KB
testcase_16 WA -
testcase_17 AC 991 ms
45,440 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 987 ms
45,312 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 798 ms
38,656 KB
testcase_28 AC 786 ms
38,656 KB
testcase_29 AC 798 ms
38,784 KB
testcase_30 AC 796 ms
38,656 KB
testcase_31 AC 791 ms
38,656 KB
testcase_32 AC 46 ms
11,904 KB
testcase_33 AC 434 ms
25,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import logging
import math
input = sys.stdin.readline
logger = logging.getLogger(__name__)


def read():
    N = int(input().strip())
    AB = []
    for i in range(N):
        a, b = map(int, input().strip().split())
        AB.append((a, b))
    return N, AB


def solve(N, AB):
    for a, b in AB:
        v = math.floor(math.sqrt(a) + math.sqrt(b))
        xs = [v-2, v-1, v, v+1, v+2]

        left = a * b
        for x_i in xs:
            right = ((x_i * x_i - a - b) // 2) ** 2
            if left < right:
                ans = x_i
                break
        print(ans)


if __name__ == "__main__":
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))
0