#P7223. [RC-04] 01 背包

[RC-04] 01 背包

Description

There is a knapsack with capacity ++\infty, and you want to put items into it.

You have nn items, and the ii-th item has volume aia_i.

You have a lucky number pp. If the sum of the volumes of the items you put in is kk, you will get a profit of pkp^k. In particular, 00=10^0=1.

Compute the sum of profits over all 2n2^n ways of choosing items to put into the knapsack. The answer is very large, so output it modulo 998244353998244353.

Input Format

The first line contains two integers n,pn,p.

The next line contains nn positive integers a1ana_1\sim a_n, describing the volumes of these nn items.

Output Format

Output one integer, the sum of profits over all 2n2^n ways modulo 998244353998244353.

2 2
1 4
51

Hint

[Sample Explanation]

The answer is 20+21+24+25=512^0+2^1+2^4+2^5=51.

[Constraints]

For all testdata, 1n1061\le n\le 10^6, 0p,ai<9982443530\le p,a_i<998244353.

The detailed constraints are shown in the table below:

Test Point ID nn pp i=1nai\sum_{i=1}^na_i Score per Test Point
11 =0=0 22
252\sim 5 22\le 22 66
696\sim 9 1000\le 1000 1000\le 1000
101410\sim 14 100000\le 100000 100000\le 100000 55
1515 2525

Translated by ChatGPT 5