P6028 Arithmetic
Background
Little W went to an arithmetic class.
Description
> As everyone knows, when Gauss was in elementary school, one day his math teacher gave a problem: $1+2+\cdots+100=?$. He thought the students would take a long time to add $100$ numbers, so he planned to slip away for coffee. But at that moment, Gauss raised his hand and said he was done—he used the arithmetic progression sum formula that we all know today.
However, the arithmetic teacher in this class is just as irresponsible as Gauss’s teacher. After leaving an arithmetic problem on the blackboard, he ran off to flirt. But Little W is not as smart as Gauss, and this expression does not seem to have any clever trick. So he called you, who study $\text{OI}$, hoping you can help him. In return, he will give you $100$ points as a reward.
Specifically, the expression on the blackboard is:
Let the prime factorization of $n$ be $n=\prod\limits_{i=1}^kp_i^{\alpha_i}$. Define $f(n)=\prod\limits_{i=1}^k{\dfrac{p_i^{\alpha_i+1}-1}{p_i^{\alpha_i+1}-p_i^{\alpha_i}}}$. Find the value of $\sum\limits_{i=1}^nf(i)$ (see the Hint and Notes for precision requirements).
**Note: In particular, we define** $f(1)=1$.
Input Format
One line with an integer $n$, as described above.
Output Format
One line with a real number representing the result.
Explanation/Hint
Explanation of Sample 2: $f(1)=1,f(2)=\dfrac{2^2-1}{2^2-2^1}=1.5,f(3)=\dfrac{3^2-1}{3^2-3^1}=1.3333333333,f(4)=\dfrac{2^3-1}{2^3-2^2}=1.75,f(5)=\dfrac{5^2-1}{5^2-5^1}=1.2$.
********
This problem uses $\text{SPJ}$. Let your answer be $a$, and the standard answer be $b$.
If $ |{a-b}|\le \min(\dfrac b{10^4},10) $, you will get full score for this test point;
otherwise, if $|{a-b}|\le \min(\dfrac b{10^3},100)$, you will get $40\%$ of the score for this test point;
otherwise, you will get no score.
The standard answer will keep 10 digits after the decimal point.
**Note: Although the precision requirement is not strict, it is still recommended to use more accurate `long double` to store the answer.**
********
Constraints:
For $10\%$ of the testdata, $n\le10$.
For $30\%$ of the testdata, $n\le10^3$.
For $60\%$ of the testdata, $n\le10^7$.
For $100\%$ of the testdata, $1\le n\le10^{13}$.
Translated by ChatGPT 5