Codeforces Round 789 (Div. 1)
F
Tokitsukaze and Gems
Codeforces
3500
原题
← E→
翻译中…

Tokitsukaze has a sequence with length of $n$. She likes gems very much. There are $n$ kinds of gems. The gems of the $i$-th kind are on the $i$-th position, and there are $a_i$ gems of the same kind on that position. Define $G(l,r)$ as the multiset containing all gems on the segment $[l,r]$ (inclusive).

翻译中…

A multiset of gems can be represented as $S=[s_1,s_2,\ldots,s_n]$, which is a non-negative integer sequence of length $n$ and means that $S$ contains $s_i$ gems of the $i$-th kind in the multiset. A multiset $T=[t_1,t_2,\ldots,t_n]$ is a multisubset of $S=[s_1,s_2,\ldots,s_n]$ if and only if $t_i\le s_i$ for any $i$ satisfying $1\le i\le n$.

翻译中…

Now, given two positive integers $k$ and $p$, you need to calculate the result of

翻译中…

$$\sum_{l=1}^n \sum_{r=l}^n\sum\limits_{[t_1,t_2,\cdots,t_n] \subseteq G(l,r)}\left(\left(\sum_{i=1}^n p^{t_i}t_i^k\right)\left(\sum_{i=1}^n[t_i \gt 0]\right)\right),$$

翻译中…

where $[t_i \gt 0]=1$ if $t_i \gt 0$ and $[t_i \gt 0]=0$ if $t_i=0$.

翻译中…

Since the answer can be quite large, print it modulo $998\,244\,353$.

翻译中…

Input

翻译中…

The first line contains three integers $n$, $k$ and $p$ ($1\le n \le 10^5$; $1\le k\le 10^5$; $2\le p\le 998\,244\,351$) — the length of the sequence, the numbers $k$ and $p$.

翻译中…

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1\le a_i\le 998\,244\,351$) — the number of gems on the $i$-th position.

翻译中…

Output

翻译中…

Print a single integers — the result modulo $998\,244\,353$.

翻译中…

样例

Input #1
5 2 2
1 1 1 2 2
Output #1
6428
InputCopy OutputCopy
Input #2
6 2 2
2 2 2 2 2 3
Output #2
338940
InputCopy OutputCopy
题目信息
题号
1677F
时间限制
4 s
内存限制
512 MB
标签
动态规划
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。