結果
| 問題 | No.8072 Sum of sqrt(x) | 
| ユーザー |  Ldio03 | 
| 提出日時 | 2021-10-25 13:33:35 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 658 bytes | 
| コンパイル時間 | 1,822 ms | 
| コンパイル使用メモリ | 81,584 KB | 
| 実行使用メモリ | 96,420 KB | 
| 最終ジャッジ日時 | 2024-10-03 04:57:48 | 
| 合計ジャッジ時間 | 16,835 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| 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,sys
from decimal import Decimal
decimal.getcontext().prec=20
inv_error = 10**20
N = int(sys.stdin.readline())
ans = Decimal(0)
for _ in range(N):
    x = int(sys.stdin.readline())
    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)
            
            
            
        