1697.
RXD and numbers
时间限制 2000 ms
内存限制 512 MB
RXD has a sequence $A_1,A_2,A_3,\dots A_n$, which possesses the following properties:
- $1\leq A_i\leq m$
- $A_1 = A_n = 1$
- for all $1\leq x\leq m$, there is at least one position $p$ where $A_p = x$.
- for all $x, y$, the number of $i(1 \leq i < n)$ which satisfies $A_i = x ~ and ~ A_{i + 1} = y$ is $D_{x, y}$.
One day, naughty boy DXR clear the sequence.
RXD wants to know, how many valid sequences are there.
Output the answer module $998244353$.
$0\leq D_{i, j}<500,1\leq m\leq 400$
$n \geq 2$
输入数据
输出数据
For each test case, output "Case #x: y", which means the test case number and the answer.
样例输入
复制
2
1 2
2 1
4
1 0 0 2
0 3 0 1
2 1 0 0
0 0 3 1
4
0 1 0 0
1 0 0 0
0 0 0 1
0 0 1 0
\n
· \n
· \n
\n
· · · \n
· · · \n
· · · \n
· · · \n
\n
· · · \n
· · · \n
· · · \n
· · · \n
样例输出
复制
Case #1: 6
Case #2: 18
Case #3: 0
· · \n
· · \n
· · \n