結果
問題 |
No.2420 Simple Problem
|
ユーザー |
![]() |
提出日時 | 2023-06-21 09:28:55 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 795 bytes |
コンパイル時間 | 193 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 77,056 KB |
最終ジャッジ日時 | 2024-06-28 19:23:52 |
合計ジャッジ時間 | 23,369 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | WA * 33 |
ソースコード
# 小数の誤差がありそうなので整数に帰着させる # 与えられたrが条件を満たすかの正確な判定 # r >= math.sqrt(a) + math.sqrt(b) # r ** 2 >= a + b + math.sqrt(a * b) # r ** 2 - a - b >= math.sqrt(a * b) # (r ** 2 - a - b) ** 2 >= a * b import math def check(a, b, r): if (r ** 2 - a - b) ** 2 >= a * b: return True else: return False def solve(a, b): # 余裕みて少し大きめな数を取って、2減らしたものまでを試す(二分探索でも全然OK) res = math.ceil(math.sqrt(a)) + math.ceil(math.sqrt(b)) if check(a, b, res - 2) == True: return res - 2 elif check(a, b, res - 1) == True: return res - 1 else: return res # main n = int(input()) for _ in range(n): a, b = map(int, input().split()) print(solve(a, b))