結果

問題 No.2420 Simple Problem
ユーザー kemunikukemuniku
提出日時 2023-08-12 15:33:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 358 ms / 2,000 ms
コード長 808 bytes
コンパイル時間 372 ms
コンパイル使用メモリ 82,384 KB
実行使用メモリ 78,556 KB
最終ジャッジ日時 2024-04-30 09:47:28
合計ジャッジ時間 13,500 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,676 KB
testcase_01 AC 180 ms
76,684 KB
testcase_02 AC 58 ms
67,976 KB
testcase_03 AC 118 ms
76,140 KB
testcase_04 AC 293 ms
77,776 KB
testcase_05 AC 207 ms
77,536 KB
testcase_06 AC 331 ms
78,108 KB
testcase_07 AC 343 ms
78,268 KB
testcase_08 AC 335 ms
78,556 KB
testcase_09 AC 358 ms
78,480 KB
testcase_10 AC 329 ms
78,044 KB
testcase_11 AC 334 ms
78,128 KB
testcase_12 AC 326 ms
78,132 KB
testcase_13 AC 346 ms
78,056 KB
testcase_14 AC 351 ms
78,548 KB
testcase_15 AC 331 ms
78,252 KB
testcase_16 AC 330 ms
78,544 KB
testcase_17 AC 341 ms
78,136 KB
testcase_18 AC 337 ms
78,104 KB
testcase_19 AC 332 ms
78,516 KB
testcase_20 AC 333 ms
78,132 KB
testcase_21 AC 331 ms
78,076 KB
testcase_22 AC 338 ms
78,100 KB
testcase_23 AC 331 ms
78,032 KB
testcase_24 AC 348 ms
77,920 KB
testcase_25 AC 335 ms
77,944 KB
testcase_26 AC 38 ms
53,560 KB
testcase_27 AC 266 ms
77,812 KB
testcase_28 AC 270 ms
77,672 KB
testcase_29 AC 268 ms
77,896 KB
testcase_30 AC 265 ms
77,684 KB
testcase_31 AC 264 ms
78,000 KB
testcase_32 AC 37 ms
53,752 KB
testcase_33 AC 187 ms
76,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#https://aotamasaki.hatenablog.com/entry/meguru_bisect
def is_ok(X):
    # 条件を満たすかどうか?問題ごとに定義
    if (X**2-A-B) < 0:
      return False
    return  4*A*B < (X**2-A-B)**2


def meguru_bisect(ng, ok):
    '''
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng ok は  とり得る最小の値-1 とり得る最大の値+1
    最大最小が逆の場合はよしなにひっくり返す
    '''
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok
N = int(input())
import sys
input = sys.stdin.readline
for i in range(N):
    A,B = map(int,input().split())
    X = meguru_bisect(0,10**5+1)
    print(X)
0