結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,188 KB
testcase_01 AC 400 ms
77,096 KB
testcase_02 AC 75 ms
72,672 KB
testcase_03 AC 203 ms
76,880 KB
testcase_04 AC 651 ms
76,976 KB
testcase_05 AC 457 ms
77,180 KB
testcase_06 AC 820 ms
77,272 KB
testcase_07 AC 804 ms
76,932 KB
testcase_08 AC 801 ms
76,892 KB
testcase_09 AC 797 ms
76,660 KB
testcase_10 AC 824 ms
76,720 KB
testcase_11 AC 804 ms
76,960 KB
testcase_12 AC 806 ms
76,868 KB
testcase_13 AC 793 ms
76,904 KB
testcase_14 AC 799 ms
76,724 KB
testcase_15 AC 814 ms
76,900 KB
testcase_16 AC 798 ms
76,904 KB
testcase_17 AC 813 ms
77,032 KB
testcase_18 AC 806 ms
77,300 KB
testcase_19 AC 805 ms
77,236 KB
testcase_20 AC 795 ms
76,908 KB
testcase_21 AC 813 ms
76,928 KB
testcase_22 AC 823 ms
76,704 KB
testcase_23 AC 798 ms
76,664 KB
testcase_24 AC 793 ms
76,880 KB
testcase_25 AC 794 ms
76,840 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 40 ms
53,412 KB
testcase_33 AC 393 ms
77,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def sqrt_by_newton(k, epsilon=0.00001):
  def f(x): return x - (x * x - k) / (2.0 * x)
  if k <= epsilon:
    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