結果
| 問題 |
No.8072 Sum of sqrt(x)
|
| ユーザー |
|
| 提出日時 | 2021-10-24 23:04:31 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 629 bytes |
| コンパイル時間 | 1,774 ms |
| コンパイル使用メモリ | 81,792 KB |
| 実行使用メモリ | 87,112 KB |
| 最終ジャッジ日時 | 2024-10-02 05:29:20 |
| 合計ジャッジ時間 | 13,053 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 4 TLE * 1 -- * 22 |
ソースコード
def sqrt_floor(x):
ceil = x
floor = 1
while ceil > floor + 1:
m = (ceil+floor)//2
if m*m <= x:
floor = m
else:
ceil = m
return floor
import decimal
from decimal import Decimal
decimal.getcontext().prec=20
inv_error = 10**20
N = int(input())
ans = Decimal(0)
for _ in range(N):
x = int(input())
p = sqrt_floor(x)
if p*p == x:
ans += p
else:
R = 1
U, V = 2, 2*p
a, b = 2*p, x-p*p
while R < inv_error:
R *= 2*p
U, V = V, a*V + b*U
ans += Decimal(V-p*U)/Decimal(U)
print(ans)