結果

問題 No.2420 Simple Problem
ユーザー Basin-Bug
提出日時 2023-08-12 15:11:55
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 365 bytes
コンパイル時間 336 ms
コンパイル使用メモリ 82,384 KB
実行使用メモリ 77,660 KB
最終ジャッジ日時 2024-11-20 00:15:05
合計ジャッジ時間 24,911 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 27 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

def sqrt_by_newton(k, epsilon=0.1):
  def f(x): return x - (x * x - k) / (2.0 * x)
  if k == 0.0:
    return 0.0
  x = k
  next_x = f(x)
  while abs(x - next_x) >= epsilon:
    x = next_x
    next_x = f(x)
  return next_x

N = int(input())
for i in range(N):
  a, b = map(int, input().split())
  m = sqrt_by_newton(a)
  n = sqrt_by_newton(b)
  print(int(m + n) + 1)
0