A15158 | Tokitsukaze and Gems
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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>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$$$.
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>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\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.
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.
输出格式
Print a single integers — the result modulo $998\,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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted