This page is still under construction.

Parts of this page are still being built. What you see may change.

Exp

Time limit5sMemory limit512 MB

Summary
Each of n independent monsters grants i experience (0 to k) with probability p_i, totals are capped at x, and the expected capped total must be computed modulo 998244353.
Level

Hard8 of 10

Topics
Probability, Dynamic programming, Math, Prefix sum
Solved
No attempts yet

Problem

Find the expected amount of experience a hero gets for beating nn monsters one by one. Beating each monster gives the hero ii units of experience (0≤i≤k0 \le i \le k) with probability pip_i, independently across monsters. If the hero's total experience exceeds xx, it is capped to exactly xx. Display the expected amount modulo 998 244 353998\,244\,353.

Input

The first line contains three integers nn, kk, and xx (1≤n≤1071 \le n \le 10^7; 1≤k≤1001 \le k \le 100; 1≤x≤min⁡(107,5⋅107/k)1 \le x \le \min(10^7, 5 \cdot 10^7/k)).

The second line contains k+1k+1 real numbers p0,p1,…,pkp_0, p_1, \ldots, p_k (0<pi<10 < p_i < 1), given with exactly 4 decimal digits. The sum of pip_i is 1.

Output

Display the expected amount of experience the hero gets.

It can be shown that the sought number can be written as an irreducible fraction p/qp/q with q≢0(mod998 244 353)q \not\equiv 0 \pmod{998\,244\,353}. Then there is a unique integer rr such that r⋅q≡p(mod998 244 353)r \cdot q \equiv p \pmod{998\,244\,353} and 0≤r<998 244 3530 \le r < 998\,244\,353, so display this rr.

Hint

In the first test case, the hero gets 0 units of experience with probability 1/41/4, 1 unit with probability 1/21/2, and 2 units with probability 1/41/4. Hence the expected amount is 1.

In the second test case, the hero gets 0 units of experience with probability 1/41/4 and 1 unit with probability 3/43/4. The expected amount is 3/43/4.

Examples4

  1. Example 1

    Input
    2 1 2
    0.5000 0.5000
    
    Expected output
    1
    
  2. Example 2

    Input
    2 1 1
    0.5000 0.5000
    
    Expected output
    249561089
    
  3. Example 3

    Input
    4 2 5
    0.2000 0.5000 0.3000
    
    Expected output
    909700083
    
  4. Example 4

    Input
    10 4 23
    0.4533 0.2906 0.1618 0.0071 0.0872
    
    Expected output
    433575862