結果

問題 No.2420 Simple Problem
ユーザー rlangevinrlangevin
提出日時 2023-09-03 15:24:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 868 ms / 2,000 ms
コード長 495 bytes
コンパイル時間 386 ms
コンパイル使用メモリ 87,048 KB
実行使用メモリ 87,704 KB
最終ジャッジ日時 2023-09-03 15:25:24
合計ジャッジ時間 28,537 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,600 KB
testcase_01 AC 448 ms
80,952 KB
testcase_02 AC 94 ms
75,900 KB
testcase_03 AC 226 ms
78,776 KB
testcase_04 AC 688 ms
84,876 KB
testcase_05 AC 490 ms
81,680 KB
testcase_06 AC 845 ms
86,236 KB
testcase_07 AC 854 ms
86,228 KB
testcase_08 AC 868 ms
85,504 KB
testcase_09 AC 832 ms
86,648 KB
testcase_10 AC 856 ms
85,984 KB
testcase_11 AC 845 ms
85,856 KB
testcase_12 AC 849 ms
85,652 KB
testcase_13 AC 862 ms
85,852 KB
testcase_14 AC 852 ms
86,780 KB
testcase_15 AC 845 ms
86,824 KB
testcase_16 AC 842 ms
85,876 KB
testcase_17 AC 853 ms
85,728 KB
testcase_18 AC 848 ms
85,784 KB
testcase_19 AC 828 ms
87,704 KB
testcase_20 AC 866 ms
85,724 KB
testcase_21 AC 823 ms
85,576 KB
testcase_22 AC 839 ms
85,780 KB
testcase_23 AC 852 ms
85,852 KB
testcase_24 AC 852 ms
85,612 KB
testcase_25 AC 818 ms
86,712 KB
testcase_26 AC 79 ms
75,188 KB
testcase_27 AC 666 ms
83,924 KB
testcase_28 AC 692 ms
83,960 KB
testcase_29 AC 665 ms
84,140 KB
testcase_30 AC 693 ms
83,976 KB
testcase_31 AC 669 ms
83,968 KB
testcase_32 AC 74 ms
71,412 KB
testcase_33 AC 443 ms
81,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from math import sqrt, ceil

def isqrt(n):
    yes = 0
    no = 10 ** 18
    while no - yes != 1:
        mid = (yes + no)//2
        if mid * mid <= n:
            yes = mid
        else:
            no = mid
    return yes * yes == n, yes
    

N = int(input())
for _ in range(N):
    A, B = map(int, input().split())
    fa, na = isqrt(A)
    fb, nb = isqrt(B)
    if fa and fb:
        print(na + nb + 1)
    else:
        print(ceil(sqrt(A) + sqrt(B)))
0