結果

問題 No.2420 Simple Problem
ユーザー pありpあり
提出日時 2023-08-12 14:07:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 872 ms / 2,000 ms
コード長 457 bytes
コンパイル時間 537 ms
コンパイル使用メモリ 82,300 KB
実行使用メモリ 77,244 KB
最終ジャッジ日時 2024-04-30 05:05:42
合計ジャッジ時間 27,070 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
51,884 KB
testcase_01 AC 409 ms
77,024 KB
testcase_02 AC 69 ms
71,936 KB
testcase_03 AC 197 ms
77,056 KB
testcase_04 AC 684 ms
76,668 KB
testcase_05 AC 468 ms
76,672 KB
testcase_06 AC 857 ms
76,800 KB
testcase_07 AC 865 ms
76,800 KB
testcase_08 AC 861 ms
76,508 KB
testcase_09 AC 832 ms
76,672 KB
testcase_10 AC 831 ms
77,056 KB
testcase_11 AC 849 ms
76,664 KB
testcase_12 AC 850 ms
76,672 KB
testcase_13 AC 872 ms
77,196 KB
testcase_14 AC 831 ms
76,808 KB
testcase_15 AC 821 ms
76,588 KB
testcase_16 AC 866 ms
76,800 KB
testcase_17 AC 846 ms
77,056 KB
testcase_18 AC 863 ms
77,244 KB
testcase_19 AC 840 ms
76,748 KB
testcase_20 AC 854 ms
76,672 KB
testcase_21 AC 832 ms
76,724 KB
testcase_22 AC 849 ms
76,640 KB
testcase_23 AC 831 ms
76,620 KB
testcase_24 AC 839 ms
76,672 KB
testcase_25 AC 846 ms
76,672 KB
testcase_26 AC 40 ms
58,496 KB
testcase_27 AC 704 ms
77,024 KB
testcase_28 AC 674 ms
77,156 KB
testcase_29 AC 683 ms
76,800 KB
testcase_30 AC 722 ms
76,644 KB
testcase_31 AC 674 ms
76,928 KB
testcase_32 AC 35 ms
51,712 KB
testcase_33 AC 391 ms
76,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())


def is_ok(mid, a, b):
  c = mid*mid-a-b
  if(c < 0):
    return False
  
  if(4*a*b < c*c):
    return True
  else:
    return False

def binary_search(ng, ok, a, b):
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if is_ok(mid, a, b):
            ok = mid
        else:
            ng = mid
    return ok




for _ in range(n):
  a,b = map(int, input().split()) 
  
  x = binary_search(0, 10**9, a, b)
  
  print(x)
    
    
0