#P6211. 「SWTR-4」Meeting in the Forest
「SWTR-4」Meeting in the Forest
Description
At the forest meeting there are cats, and the strength value of each cat is . So Juxing wrote down the following equation:
- In plain words, this equation is .
With their excellent (cu) math skills, Juxing knows that this equation has roots in the complex numbers. Let these roots be .
Next, Juxing wants to know how strong the cats at the forest meeting are, so they wrote the following expression:
$$\sum_{i=1}^{n}(b_i\times \sum_{1\le j_1 < j_2 <\cdots< j_i \le n}^{n}x_{j_1}x_{j_2}\cdots x_{j_i})$$- $\sum_{1\le j_1 < j_2 < \cdots < j_i \le n}^{n}x_{j_1}x_{j_2}\cdots x_{j_i}$ means: choose roots from the roots of the equation, and sum the products of the chosen roots over all possible choices.
But Juxing only needs the value of this expression modulo .
- If the answer is a negative number , please output .
Juxing gives this task to you. They have already told you , , and $b_i. Can you help them?
Input Format
The first line contains an integer — the degree of the equation.
The second line contains integers — as described in the statement.
The third line contains integers — same as above.
Output Format
Output one line containing one number, the value of this expression modulo .
2
-2 1
1 1
3
3
-3 0 4
2 3 4
999999997
Hint
Sample 1 Explanation:
The original equation is , and .
The value of the expression is .
Sample 2 Explanation:
The original equation is , and .
The value of the expression is
$$\begin{aligned}&2\cdot (x_1+x_2+x_3)+3\cdot(x_1x_2+x_1x_3+x_2x_3)+4\cdot x_1x_2x_3\\=\ &2\times(-1+2+2)+3\times(-2+(-2)+4)+4\times (-4)\\=\ &-10\end{aligned}$$Since is negative, output .
Constraints:
For of the testdata, .
For another of the testdata, .
For of the testdata, .
For of the testdata, .
For of the testdata, , .
Tips:
Vieta's formulas may be helpful.
Source:
idea & std: 蒟蒻的名字
Translated by ChatGPT 5
京公网安备 11011102002149号