P3198 [HNOI2008] Distant Planets
Description
There are $N$ planets on a line; planet $i$ is located at position $X = i$. Planet $J$ is affected by the force from planet $I$ if and only if $i \le A J$. In this case, the magnitude of the force on $J$ is $F_{i->j}=\frac{M_i \times M_j}{j-i}$.
Here $A$ is a very small constant, so intuitively each planet is only affected by planets that are far away. Compute the force on each planet. The answer is accepted if the relative error does not exceed 5%.
Input Format
The first line contains an integer $N$ and a real number $A$.
The next $N$ lines contain the masses $M_i$ of the $N$ planets.
Output Format
Output $N$ lines, the force on each planet in order.
Explanation/Hint
$1 \le N \le 10^5$.
$0.01 < A \le 0.35$.
$0 \le M_i \le 10^7$.
Translated by ChatGPT 5