题目描述:
Given an integer n, we only want to know the sum of 1/(k * k) where k from 1 to n.
Input
There are multiple cases.
For each test case, there is a single line, containing a single positive integer n.
The input file is at most 1M.
Output
The required sum, rounded to the fifth digits after the decimal point.
Sample Input
|
|
Sample Output
|
|
题解:
需要注意的问题:
- 计算sum的时候不要
1.0 / (i * i)
这样计算, 要1.0 / i / i
这样计算。 - 题目中没说n额具体范围, 只说了
n >= 0
那就认为n无限大, 用字符串存储, 也同时意味着有规律可寻。
ac代码:
|
|
|
|