結果

問題 No.2420 Simple Problem
ユーザー Basin-BugBasin-Bug
提出日時 2023-08-12 15:13:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 366 bytes
コンパイル時間 482 ms
コンパイル使用メモリ 82,076 KB
実行使用メモリ 77,400 KB
最終ジャッジ日時 2024-04-30 08:26:46
合計ジャッジ時間 26,226 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,536 KB
testcase_01 AC 404 ms
76,776 KB
testcase_02 AC 79 ms
72,720 KB
testcase_03 AC 211 ms
76,848 KB
testcase_04 AC 669 ms
77,056 KB
testcase_05 AC 467 ms
76,756 KB
testcase_06 AC 805 ms
76,632 KB
testcase_07 AC 809 ms
77,040 KB
testcase_08 AC 797 ms
76,964 KB
testcase_09 AC 818 ms
76,596 KB
testcase_10 AC 808 ms
76,904 KB
testcase_11 AC 795 ms
77,324 KB
testcase_12 AC 804 ms
77,036 KB
testcase_13 AC 793 ms
76,884 KB
testcase_14 AC 795 ms
77,028 KB
testcase_15 AC 805 ms
76,828 KB
testcase_16 AC 808 ms
77,028 KB
testcase_17 AC 805 ms
76,880 KB
testcase_18 AC 797 ms
77,040 KB
testcase_19 AC 791 ms
76,992 KB
testcase_20 AC 795 ms
77,232 KB
testcase_21 AC 789 ms
76,960 KB
testcase_22 AC 810 ms
76,844 KB
testcase_23 AC 804 ms
76,860 KB
testcase_24 AC 797 ms
76,908 KB
testcase_25 AC 785 ms
76,980 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 37 ms
52,068 KB
testcase_33 AC 376 ms
77,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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