#P5349. 幂
幂
Description
$$\text{Find}\ \sum_{n=0}^{\infty}f(n)\ r^n\ ,\ f(n)\text{ is a polynomial},\ r\text{ is a rational number in }(0,1)$$If the simplest fraction form of the answer is , you only need to output the value of .
Input Format
The first line contains two integers . is the degree of the polynomial.
The second line contains integers. The -th integer is the coefficient of .
Output Format
Only one line with one number, which is the answer.
1 499122177
0 1
2
2 748683265
0 0 1
628524223
3 713031681
7 5 23 2
257147786
Hint
For of the testdata, .
For of the testdata, .
For of the testdata, , and it is guaranteed that .
Bundled Tests
Sample 1 Explanation:
$499122177\equiv \frac{1}{2}\ (\mathrm{mod}\ 998244353)$.
.
Sample 2 Explanation:
$748683265\equiv \frac{1}{4}\ (\mathrm{mod}\ 998244353)$.
$\sum_{n=0}^{\infty}n^2\ (\frac{1}{4})^n=\frac{20}{27}$.
Sample 3 Explanation:
$713031681\equiv \frac{2}{7}\ (\mathrm{mod}\ 998244353)$.
$\sum_{n=0}^{\infty}(2n^3+23n^2+5n+7)\ (\frac{2}{7})^n=\frac{25417}{625}$.
Translated by ChatGPT 5
京公网安备 11011102002149号