結果

問題 No.2420 Simple Problem
ユーザー Kyoro IDKyoro ID
提出日時 2023-08-13 09:11:12
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 872 bytes
コンパイル時間 148 ms
コンパイル使用メモリ 82,140 KB
実行使用メモリ 96,004 KB
最終ジャッジ日時 2024-05-01 02:47:34
合計ジャッジ時間 18,907 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,716 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 467 ms
91,732 KB
testcase_28 AC 479 ms
91,604 KB
testcase_29 AC 473 ms
91,608 KB
testcase_30 AC 480 ms
91,736 KB
testcase_31 AC 469 ms
91,480 KB
testcase_32 AC 66 ms
71,772 KB
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

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 judge(x, a, b):
    left = a * b * 4
    right = (x * x - a - b) * (x * x - a - b)
    return left < right


def solve(N, AB):
    for a, b in AB:
        ok = 10**11
        ng = 2
        while abs(ok - ng) > 1:
            x = (ok + ng) // 2
            if judge(x, a, b):
                ok = x
            else:
                ng = x
        for x in (ok-1, ok, ok+1):
            if judge(x, a, b):
                print(x)
                break


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