#P7489. 「Stoi2031」手写的从前
「Stoi2031」手写的从前
Description
Yuan defines the weight of a set as , where is the sum of all elements in , and is the product of all elements in . Tian asks him: what is the sum of the weights of all subsets of a set ? Yuan quickly computes the answer. Tian then asks: what is the sum of the sums of the weights of all subsets of all subsets? Yuan also computes it quickly. So Tian asks one more question: in the question there are a total of layers of all subsets. Now Yuan cannot finish it, so he asks you for help. Yuan does not need an excessively large number, so you only need to output the answer modulo .
Input Format
The first line contains three positive integers , where is the number of elements in .
The second line contains positive integers, representing the elements of .
Output Format
Output one positive integer as the answer. It is guaranteed that the answer is meaningful modulo .
3 1 7
1 2 3
3
3 10 7
1 2 3
4
Hint
Brief statement of the problem:
Let , and . Here is the sum of all elements in , and is the product of all elements in . Given and the set , find .
Sample explanation:
Due to space limits, only sample is explained.
Enumerate subsets:
, with value ;
, with value ;
, with value ;
, with value ;
, with value ;
, with value ;
, with value ;
, with value ;
The total sum is , which is modulo .
Constraints:
For of the testdata, .
For of the testdata, .
For of the testdata, $1 \le n \le 7 \times 10^6,1 \le k \le 10^{18},1 \le x_i<p,1<p<2^{31},p$ is prime, and all are distinct.
The input size of this problem is large. You may use the fast input template from the contest statement to speed up reading.
Translated by ChatGPT 5
京公网安备 11011102002149号