Given the sequence a[0\dots n], ask the value of
\sum\limits_{i=0}^{n}\sum\limits_{j=0}^{a_i} P(i, j) \mod 998241383
wikipedia: k-permutations of n are the different ordered arrangements of a k-element subset of an n-set (sometimes called variations or arrangements in the older literature). These objects are also known as partial permutations or as sequences without repetition, terms that avoid confusion with the other, more common, meaning of "permutation". The number of such k-permutations of n is denoted variously by such symbols as P_k^n or P(n,k),and its value is given by the product P(n,k)=\underbrace {n\cdot (n-1)\cdot (n-2)\cdots (n-k+1)} _{k\ \mathrm {factors} }, which is 0 when k>n, and otherwise is equal to \frac {n!}{(n-k)!}.
Assume that P(i, 0) = 1, P(0, 0) = 1
输入
The first line contains an integer T(T \leq 3) — the number of test cases you need to solve.
The first line of each test case contains an integer n(1 \leq n \leq 10^5).
The second line contains n space-separated integers a_0, a_1, \cdots, a_n (0 \leq a_i \leq i) — the elements of the array a.
输出
For each test case, print the result mod naughty 998241383.
样例
标准输入 复制文本 |
1 5 0 1 1 3 2 4 |
标准输出 复制文本 |
245 |
提示
\sum\limits_{i=0}^{0}{P(0, i)}=1
\sum\limits_{i=0}^{1}{P(1, i)}=1+1=2
\sum\limits_{i=0}^{1}{P(2, i)}=1+2=3
\sum\limits_{i=0}^{3}{P(3, i)}=1+3+6+6=16
\sum\limits_{i=0}^{2}{P(4, i)}=1+4+12=17
\sum\limits_{i=0}^{4}{P(5, i)}=1+5+20+60+120=206
来源
2021 GDCPC 广东省大学生程序设计竞赛