NOIP '21 P2 - Sequence

View as PDF

Submit solution

Points: 20 (partial)
Time limit: 1.0s
Memory limit: 512M

Problem types

You are given integers n,m,k and m+1 positive integers v0,v1,,vm.

For a one-based array {ai} containing n integers between 0 and m, its weight is defined as va1×va2××van.

Such an array {ai} is valid if S=2a1+2a2++2an contains no more than k ones in its binary representation.

Calculate the sum of weights of all valid arrays {ai}. Output the sum modulo 998244353.

Input Specification

The first line contains 3 integers n,m,k.

The second line contains m+1 integers v0,v1,,vm.

Output Specification

Output a single integer, the sum of weights of all valid arrays modulo 998244353.

Sample Input

Copy
5 1 1
2 1

Sample Output

Copy
40

Sample 1 Explanation

Because k is 1 and nSn×2m implies 5S10, there is only one possible S: S=8. This requires that a contains two 0s and three 1s. Thus, we have (52)=10 valid arrays. Each array has weight v02v13=4. The sum is 40.

Additional Samples

Additional samples can be found here.

Constraints

For all test cases, 1kn30, 0m100, 1vi<998244353.

Test cases n k m
14 =8 n =9
57 =30 =7
810 =12
1113 =1 =100
1415 =5 n =50
16 =15 =100
1718 =30 =30
1920 =100

Comments

There are no comments at the moment.