結果
| 問題 | No.2420 Simple Problem |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-12 15:19:29 |
| 言語 | Python3 (3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL) |
| 結果 |
TLE
不安定
|
| 実行時間 | - |
| コード長 | 415 bytes |
| 記録 | |
| コンパイル時間 | 53 ms |
| コンパイル使用メモリ | 15,104 KB |
| 実行使用メモリ | 11,392 KB |
| 最終ジャッジ日時 | 2026-09-26 21:00:51 |
| 合計ジャッジ時間 | 100,649 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 6 WA * 1 TLE * 26 |
ソースコード
from decimal import Decimal
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(Decimal(m) + Decimal(n)) + 1)