結果

問題 No.2420 Simple Problem
ユーザー FromBooskaFromBooska
提出日時 2023-08-18 20:51:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 683 ms / 2,000 ms
コード長 511 bytes
コンパイル時間 1,571 ms
コンパイル使用メモリ 81,816 KB
実行使用メモリ 76,800 KB
最終ジャッジ日時 2024-05-06 02:17:40
合計ジャッジ時間 23,745 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,352 KB
testcase_01 AC 326 ms
76,672 KB
testcase_02 AC 65 ms
69,120 KB
testcase_03 AC 159 ms
76,544 KB
testcase_04 AC 539 ms
76,672 KB
testcase_05 AC 372 ms
76,380 KB
testcase_06 AC 655 ms
76,416 KB
testcase_07 AC 681 ms
76,612 KB
testcase_08 AC 656 ms
76,288 KB
testcase_09 AC 661 ms
76,416 KB
testcase_10 AC 683 ms
76,288 KB
testcase_11 AC 671 ms
76,288 KB
testcase_12 AC 667 ms
76,276 KB
testcase_13 AC 661 ms
76,160 KB
testcase_14 AC 663 ms
75,904 KB
testcase_15 AC 655 ms
75,904 KB
testcase_16 AC 661 ms
76,160 KB
testcase_17 AC 672 ms
76,032 KB
testcase_18 AC 655 ms
76,256 KB
testcase_19 AC 656 ms
76,800 KB
testcase_20 AC 663 ms
76,552 KB
testcase_21 AC 660 ms
76,672 KB
testcase_22 AC 653 ms
75,904 KB
testcase_23 AC 669 ms
76,196 KB
testcase_24 AC 655 ms
76,416 KB
testcase_25 AC 665 ms
76,212 KB
testcase_26 AC 38 ms
52,224 KB
testcase_27 AC 526 ms
76,672 KB
testcase_28 AC 549 ms
76,328 KB
testcase_29 AC 524 ms
75,904 KB
testcase_30 AC 519 ms
76,588 KB
testcase_31 AC 532 ms
76,288 KB
testcase_32 AC 36 ms
52,480 KB
testcase_33 AC 323 ms
76,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 10**9全探索はできないがsqrt(10**6)なら全探索可能
# A < Bとする

from math import floor, ceil

T = int(input())
for t in range(T):
    A, B = map(int, input().split())
    if A > B:
        A, B = B, A

    mn = floor(A**0.5)*2
    mx = ceil(B**0.5)*2
    #print('mn', mn, 'mx', mx)
    
    NG = mn 
    OK = mx+10
    
    while OK-NG>1:
        mid = (OK+NG)//2
        if (mid**2-A-B) > 0 and 4*A*B < (mid**2-A-B)**2:
            OK = mid
        else:
            NG = mid
    print(OK)
0