結果
問題 |
No.8072 Sum of sqrt(x)
|
ユーザー |
|
提出日時 | 2021-10-24 23:02:23 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 629 bytes |
コンパイル時間 | 513 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 89,216 KB |
最終ジャッジ日時 | 2024-10-02 05:26:41 |
合計ジャッジ時間 | 12,242 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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)/Decimal(U) - p print(ans)