#P6620. [省选联考 2020 A 卷] 组合数问题
[省选联考 2020 A 卷] 组合数问题
Description
As everyone knows, student Xiaocong is good at calculations, especially at computing binomial coefficients. Now Xiaocong wants you to compute
$$\left(\sum_{k=0}^{n}f(k)\times x^k\times \binom{n}{k}\right)\bmod p$$where , , and are given integers, and is a given degree polynomial . is the binomial coefficient, defined as .
Input Format
The first line contains four non-negative integers , , , .
The second line contains integers, representing , , , .
Output Format
Output one integer in a single line, which is the answer.
5 1 10007 2
0 0 1
240
996 233 998244353 5
5 4 13 16 20 15
869469289
Hint
Sample 1 Explanation
$f(0) = 0,f(1) = 1,f(2) = 4,f(3) = 9,f(4) = 16,f(5) = 25$.
, so is always , and this factor in each term of the product can be ignored.
$\binom 5 0 = 1, \binom 5 1 = 5, \binom 5 2 = 10, \binom 5 3 = 10, \binom 5 4 = 5, \binom 5 5 = 1$.
Sample 3
See the attached files problem3.in and problem3.ans.
Constraints and Hints
For all testdata: $1\le n, x, p \le 10^9, 0\le a_i\le 10^9, 0\le m \le \min(n,1000)$.
The specific limits for each test point are shown in the table below:
| Test Point ID | Other Special Limits | ||
|---|---|---|---|
| is prime. | |||
Translated by ChatGPT 5
京公网安备 11011102002149号