4582: F

内存限制:128 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:Special Judge 上传者:
提交:0 通过:0

题目描述

Given the sequence a[0 . . . n] ,ask the value of




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 Pkn or P(n, k),and its value is given by the product P(n, k) = n · (n − 1) · (n − 2)· · ·(n − k + 1) | {z } k factors ,which is 0 when k > n, and otherwise is equal to n! (n−k)! .

Assume that P(i, 0) = 1, P(0, 0) = 1

输入格式

The first line contains an integer T(T ≤ 3) — the number of test cases you need to solve. The first line of each test case contains an integer n(1 ≤ n ≤ 105). The second line contains n space-separated integers a0, a1, · · · , an(0 ≤ ai ≤ 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

分类标签