結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
53,692 KB
testcase_01 AC 337 ms
76,948 KB
testcase_02 AC 61 ms
72,424 KB
testcase_03 AC 170 ms
77,196 KB
testcase_04 AC 568 ms
76,840 KB
testcase_05 AC 385 ms
76,856 KB
testcase_06 AC 688 ms
76,640 KB
testcase_07 AC 679 ms
76,892 KB
testcase_08 AC 691 ms
77,092 KB
testcase_09 AC 706 ms
77,296 KB
testcase_10 AC 700 ms
76,700 KB
testcase_11 AC 680 ms
77,244 KB
testcase_12 AC 699 ms
76,848 KB
testcase_13 AC 682 ms
76,968 KB
testcase_14 AC 689 ms
77,156 KB
testcase_15 AC 684 ms
76,524 KB
testcase_16 AC 682 ms
76,904 KB
testcase_17 AC 713 ms
77,036 KB
testcase_18 AC 674 ms
77,212 KB
testcase_19 AC 686 ms
76,660 KB
testcase_20 AC 703 ms
77,084 KB
testcase_21 AC 681 ms
77,240 KB
testcase_22 AC 697 ms
76,844 KB
testcase_23 AC 672 ms
76,652 KB
testcase_24 AC 698 ms
76,980 KB
testcase_25 AC 691 ms
76,880 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 32 ms
52,072 KB
testcase_33 AC 351 ms
76,908 KB
権限があれば一括ダウンロードができます

ソースコード

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