CF1677F.Tokitsukaze and Gems
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 ai 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=[s1,s2,…,sn] , which is a non-negative integer sequence of length n and means that S contains si gems of the i -th kind in the multiset. A multiset T=[t1,t2,…,tn] is a multisubset of S=[s1,s2,…,sn] if and only if ti≤si for any i satisfying 1≤i≤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>0]\right)\right), $$ </p><p>where $\[t\_i>0\]=1$ if $t\_i>0$ and $\[t\_i>0\]=0$ if $t\_i=0$ .</p><p>Since the answer can be quite large, print it modulo $998\\,244\\,353$$$.输入格式
The first line contains three integers n , k and p ( 1≤n≤105 ; 1≤k≤105 ; 2≤p≤998244351 ) — the length of the sequence, the numbers k and p .
The second line contains n integers a1,a2,…,an ( 1≤ai≤998244351 ) — the number of gems on the i -th position.
输出格式
Print a single integers — the result modulo 998244353 .
输入输出样例
输入#1
5 2 2 1 1 1 2 2
输出#1
6428
输入#2
6 2 2 2 2 2 2 2 3
输出#2
338940