CF1677F.Tokitsukaze and Gems

NOI/NOI+/CTSC

通过率:0%

时间限制:4.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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

A multiset of gems can be represented as S=[s1,s2,…,sn]S=[s_1,s_2,\ldots,s_n], which is a non-negative integer sequence of length nn and means that SS contains sis_i gems of the ii-th kind in the multiset. A multiset T=[t1,t2,…,tn]T=[t_1,t_2,\ldots,t_n] is a multisubset of S=[s1,s2,…,sn]S=[s_1,s_2,\ldots,s_n] if and only if ti≤sit_i\le s_i for any ii satisfying 1≤i≤n1\le i\le n.

Now, given two positive integers kk and pp, 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 [ti>0]=1[t_i \gt 0]=1 if ti>0t_i \gt 0 and [ti>0]=0[t_i \gt 0]=0 if ti=0t_i=0.

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

Tokitsukaze 有一个长度为 nn 的序列。她非常喜欢宝石。一共有 nn 种宝石,第 ii 种宝石位于第 ii 个位置,该位置上有 aia_i 颗同种宝石。定义 G(l,r)G(l,r) 为区间 [l,r][l,r](含端点)上所有宝石构成的多重集。

一个宝石多重集可表示为 S=[s1,s2,…,sn]S=[s_1,s_2,\ldots,s_n],即一个长度为 nn 的非负整数序列,其含义是:多重集 SS 中包含 sis_i 颗第 ii 种宝石。多重集 T=[t1,t2,…,tn]T=[t_1,t_2,\ldots,t_n] 是多重集 S=[s1,s2,…,sn]S=[s_1,s_2,\ldots,s_n] 的多重子集,当且仅当对任意满足 1≤i≤n1\le i\le n 的 ii,均有 ti≤sit_i\le s_i。

现给定两个正整数 kk 和 pp,你需要计算下列表达式的值:

∑l=1n∑r=ln∑[t1,t2,⋯ ,tn]⊆G(l,r)((∑i=1nptitik)(∑i=1n[ti>0])),\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),

其中 [ti>0]=1[t_i > 0]=1 当 ti>0t_i > 0,否则 [ti>0]=0[t_i > 0]=0。

由于答案可能非常大,请将结果对 998 244 353998\,244\,353 取模后输出。

输入格式

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

The second line contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤998 244 3511\le a_i\le 998\,244\,351) — the number of gems on the ii-th position.

第一行包含三个整数 nn、kk 和 pp(1≤n≤1051\le n \le 10^5;1≤k≤1051\le k\le 10^5;2≤p≤998 244 3512\le p\le 998\,244\,351)—— 分别表示序列长度、数字 kk 和 pp。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(1≤ai≤998 244 3511\le a_i\le 998\,244\,351)—— 表示第 ii 个位置上的宝石数量。

输出格式

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

输出一个整数——结果对 998 244 353998\,244\,353 取模的值。

输入输出样例

  • 输入#1

    5 2 2
    1 1 1 2 2

    输出#1

    6428
  • 输入#2

    6 2 2
    2 2 2 2 2 3

    输出#2

    338940

输入解题思路,AI测评打分。不知道怎么写?

首页