結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
12,032 KB
testcase_01 AC 390 ms
25,600 KB
testcase_02 AC 50 ms
12,032 KB
testcase_03 AC 173 ms
16,896 KB
testcase_04 AC 705 ms
38,400 KB
testcase_05 AC 459 ms
28,800 KB
testcase_06 AC 854 ms
45,184 KB
testcase_07 AC 854 ms
45,312 KB
testcase_08 AC 848 ms
45,312 KB
testcase_09 AC 861 ms
45,312 KB
testcase_10 AC 850 ms
45,312 KB
testcase_11 AC 853 ms
45,312 KB
testcase_12 AC 850 ms
45,440 KB
testcase_13 AC 861 ms
45,440 KB
testcase_14 AC 855 ms
45,184 KB
testcase_15 AC 864 ms
45,312 KB
testcase_16 AC 862 ms
45,440 KB
testcase_17 AC 848 ms
45,312 KB
testcase_18 AC 860 ms
45,312 KB
testcase_19 AC 850 ms
45,312 KB
testcase_20 AC 854 ms
45,312 KB
testcase_21 AC 853 ms
45,184 KB
testcase_22 AC 848 ms
45,184 KB
testcase_23 AC 851 ms
45,312 KB
testcase_24 AC 859 ms
45,312 KB
testcase_25 AC 854 ms
45,312 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 45 ms
11,776 KB
testcase_33 AC 371 ms
25,344 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:
        vv = 2 * math.sqrt(a * b) + a + b
        x = math.floor(math.sqrt(vv))
        for x_i in (x-2, x-1, x, x+1, x+2):
            if vv < x_i * x_i:
                ans = x_i
                break
        print(ans)


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