結果
問題 | No.2420 Simple Problem |
ユーザー |
|
提出日時 | 2024-03-06 18:37:37 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 653 bytes |
コンパイル時間 | 213 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-09-29 18:33:09 |
合計ジャッジ時間 | 65,356 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 13 TLE * 20 |
ソースコード
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()