問題一覧 > 教育的問題

No.8072 Sum of sqrt(x)

レベル : / AI推定難易度 : 1750 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 小数誤差許容問題 絶対誤差または相対誤差が $10^{-15}$ 以下。ただし、ジャッジ側の都合で500桁未満にしてください
タグ : (AC するまで非表示) / 解いたユーザー数 21
作問者 : trineutron / テスター : maspy
お気に入りにしたユーザー ProblemId : 3867 / 自分の提出
問題文最終更新日: 2022-04-26 02:10:16
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original

Problem Statement

You are given a sequence $x_1, x_2, \dots, x_N$ of length $N$. For each integer $k$ satisfying $1 \le k \le N$, find $\sum_{i=1}^k \sqrt{x_i}$. Your answer is considered correct if the smaller of the absolute error and the relative error is at most $10^{-15}$.

Note that the allowed error is set very strictly. Since the amount of input and output is large, use fast I/O. You may not be able to get AC in languages other than C, C++, and Python3. Note that outputting 20MB or more results in OLE.

Input

$N$
$x_1$
$x_2$
$\vdots$
$x_N$

All inputs are integers.
$1 \le N \le 10^6$
$0 \le x_i \lt 10^{18}$

Output

Output $N$ lines. On the $k$-th line, output $\sum_{i=1}^k \sqrt{x_i}$.

Sample

Sample 1
Input
3
3
4
5
Output
1.73205080756887729
3.73205080756887729
5.96811878506866699

The 1st line is $\sqrt{3}$, the 2nd line is $\sqrt{3}+\sqrt{4}$, and the 3rd line is $\sqrt{3}+\sqrt{4}+\sqrt{5}$. Your answer is considered correct if the smaller of the absolute error and the relative error is at most $10^{-15}$.

Sample 2
Input
2
999999999999999999
0
Output
999999999.999999999
999999999.999999999

Sample 3
Input
10
2
2
2
2
2
2
2
2
2
2
Output
1.41421356237309505
2.8284271247461901
4.24264068711928515
5.6568542494923802
7.07106781186547524
8.48528137423857029
9.89949493661166534
11.3137084989847604
12.7279220613578554
14.1421356237309505

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。