結果

問題 No.2420 Simple Problem
ユーザー Basin-BugBasin-Bug
提出日時 2023-08-12 15:16:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 369 bytes
コンパイル時間 133 ms
コンパイル使用メモリ 82,420 KB
実行使用メモリ 77,636 KB
最終ジャッジ日時 2024-04-30 08:42:31
合計ジャッジ時間 22,506 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,368 KB
testcase_01 AC 343 ms
77,136 KB
testcase_02 AC 65 ms
73,300 KB
testcase_03 AC 180 ms
76,724 KB
testcase_04 AC 571 ms
76,760 KB
testcase_05 AC 387 ms
77,040 KB
testcase_06 AC 682 ms
77,636 KB
testcase_07 AC 687 ms
76,972 KB
testcase_08 AC 689 ms
76,964 KB
testcase_09 AC 685 ms
76,884 KB
testcase_10 AC 721 ms
76,516 KB
testcase_11 AC 696 ms
76,704 KB
testcase_12 AC 721 ms
76,844 KB
testcase_13 AC 684 ms
76,952 KB
testcase_14 AC 707 ms
76,868 KB
testcase_15 AC 720 ms
77,232 KB
testcase_16 AC 704 ms
77,144 KB
testcase_17 AC 707 ms
76,952 KB
testcase_18 AC 698 ms
76,824 KB
testcase_19 AC 712 ms
77,300 KB
testcase_20 AC 697 ms
76,908 KB
testcase_21 AC 695 ms
76,848 KB
testcase_22 AC 697 ms
77,160 KB
testcase_23 AC 710 ms
77,372 KB
testcase_24 AC 696 ms
76,844 KB
testcase_25 AC 686 ms
76,844 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 33 ms
53,352 KB
testcase_33 AC 322 ms
76,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def sqrt_by_newton(k, epsilon=0.00001):
  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