No.8072 Sum of sqrt(x)
タグ : / 解いたユーザー数 21
作問者 :
trineutron
/ テスター :
maspy
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もしくは右上の雲マークをクリックしてアカウントを作成してください。