結果
問題 | No.2420 Simple Problem |
ユーザー |
|
提出日時 | 2024-03-06 18:57:16 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 549 ms / 2,000 ms |
コード長 | 653 bytes |
コンパイル時間 | 599 ms |
コンパイル使用メモリ | 82,688 KB |
実行使用メモリ | 77,184 KB |
最終ジャッジ日時 | 2024-09-29 18:32:46 |
合計ジャッジ時間 | 19,133 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 33 |
ソースコード
from itertools import count from math import sqrt import sys def printe(*args, end="\n", **kwargs): print(*args, end=end, file=sys.stderr, **kwargs) def main(): N = int(input()) for _ in range(N): A, B = map(int, input().split()) X_floor = sqrt(A) + sqrt(B) for num in count(int(X_floor - 3)): if num < 1: continue if num**2 - A - B <= 0: continue if 4 * A * B < (num**2 - A - B)**2: print(num) break # A+B+2√AB < X^2 # 2√AB < X^2-A-B # 4AB < (X^2-A-B)^2 if __name__ == "__main__": main()