You are given integers $$$N,M,K,R,C,$$$ and $$$V$$$. Find the number of $$$N$$$ by $$$M$$$ integer matrices $$$a = (a_{i,j})$$$ that satisfy all of the following conditions, modulo $$$998244353$$$.
The first line contains integers $$$N$$$, $$$M$$$ ($$$1 \leq N,M \leq 200$$$), $$$K$$$ ($$$1 \leq K \leq 100$$$), $$$R$$$ ($$$1 \leq R \leq N$$$), $$$C$$$ ($$$1 \leq C \leq M$$$), and $$$V$$$ ($$$1 \leq V \leq K$$$).
Print the answer.
2 2 2 1 1 1
5
2 2 2 1 2 1
3
4 5 6 2 3 4
3700125
200 100 100 70 60 30
546626227
You are given an integer array $$$A$$$ of length $$$N$$$, consisting of $$$0$$$'s and $$$1$$$'s. Let $$$a$$$ be initially the array $$$A$$$. You are going to perform the following operation $$$N-1$$$ times.
There are $$$2^{N-1} \times (N-1)!$$$ ways to perform the operations. Count the number of ways that result in a single value of $$$1$$$, modulo $$$998244353$$$.
The first line contains an integer $$$N$$$ ($$$1 \leq N \leq 10^6$$$).
The second line contains integers $$$A_1,A_2,\ldots,A_N$$$ ($$$0 \leq A_i \leq 1$$$).
Print the answer.
3 0 1 0
2
5 1 1 1 1 1
384
7 0 1 1 0 1 0 1
25515
You have $$$R$$$ red balls, $$$B$$$ blue balls, and one green ball. You are going to arrange the balls in a row. The score of an arrangement is defined as follows:
Find the sum of scores of all possible arrangements, modulo $$$998244353$$$. Note that balls of the same color cannot be distinguished, thus two arrangements are considered different if and only if there is such an $$$i$$$ that the color of the $$$i$$$-th ball in the first arrangement differs from that of the second.
The first line contains integers $$$R$$$ ($$$1 \leq R \leq 10^{18}$$$) and $$$B$$$ ($$$1 \leq B \leq 10^6$$$).
Print the answer.
10 3
8390
3 10
0
100 10
801171977
999999999999999999 999999
448294209
You are given integer sequences $$$A$$$, $$$B$$$, and $$$C$$$, each of length $$$N$$$. For each $$$k=1,2,\ldots,N$$$, find the following value modulo $$$998244353$$$.
$$$$$$ \sum_{1 \leq i \leq N} \left( C_i \times \prod_{1 \leq j \leq k} (A_i+B_j) \right) $$$$$$
The first line contains an integer $$$N$$$ ($$$1 \leq N \leq 250000$$$).
The second line contains $$$N$$$ integers $$$A_1,A_2,\ldots,A_N$$$ ($$$0 \leq A_i \lt 998244353$$$).
The third line contains $$$N$$$ integers $$$B_1,B_2,\ldots,B_N$$$ ($$$0 \leq B_i \lt 998244353$$$).
The fourth line contains $$$N$$$ integers $$$C_1,C_2,\ldots,C_N$$$ ($$$0 \leq C_i \lt 998244353$$$).
For each $$$k=1,2,\ldots,N$$$, print the answer.
3 1 2 3 4 5 6 7 8 9
146 1050 8694
You are given integers $$$A,B$$$, and a simple undirected graph of $$$N$$$ vertices and $$$M$$$ edges. The vertices are numbered from $$$1$$$ through $$$N$$$, and the edges from $$$1$$$ through $$$M$$$. The edge $$$i$$$ connects the vertices $$$U_i$$$ and $$$V_i$$$. Here, it is guaranteed that $$$V_i-U_i=A$$$ or $$$V_i-U_i=B$$$.
Find the number of matchings of the graph, modulo $$$998244353$$$. Note that a matching of the graph is a subset of edges whose end-points are all distinct.
The first line contains integers $$$N$$$ ($$$3 \leq N \leq 200$$$), $$$M$$$ ($$$1 \leq M \leq 400$$$), $$$A$$$, and $$$B$$$ ($$$1 \leq A \lt B \leq N-1$$$).
The following $$$M$$$ lines describe the edges. The $$$i$$$-th of those lines contains integers $$$U_i$$$ and $$$V_i$$$ ($$$1 \leq U_i \lt V_i \leq N$$$, $$$V_i-U_i=A$$$ or $$$V_i-U_i=B$$$). There are no self-loops or multi-edges.
Print the answer.
4 3 1 2 1 2 1 3 3 4
5
10 14 2 4 5 7 7 9 2 6 6 8 1 5 3 7 4 8 1 3 4 6 8 10 3 5 5 9 2 4 6 10
225
You are given an integer sequence $$$A_1,A_2,\ldots,A_N$$$. You'll make a rooted tree with $$$N$$$ vertices numbered from $$$1$$$ through $$$N$$$. The vertex $$$1$$$ is the root, and for each vertex $$$i$$$ ($$$2 \leq i \leq N$$$), its parent $$$p_i$$$ must satisfy $$$p_i \lt i$$$.
You define the score of a rooted tree as follows:
$$$$$$ \prod_{v \in (\text{subtree rooted at $x$})} A_v $$$$$$
Note that we consider $$$x$$$ itself is in the subtree rooted at $$$x$$$.
There are $$$(N-1)!$$$ ways to make a tree. Find the sum of scores of all possible trees, modulo $$$998244353$$$.
The first line contains an integer $$$N$$$ ($$$3 \leq N \leq 250000$$$).
The second line contains integers $$$A_1,A_2,\ldots,A_N$$$ ($$$1 \leq A_i \lt 998244353$$$).
Print the answer.
3 2 2 2
12
5 1 2 3 4 5
2080
You are given an integer sequence $$$A_1,A_2,\ldots,A_N$$$ and an integer $$$K$$$.
You'll prepare $$$K$$$ piles of stones. Each pile should contain exactly $$$A_i$$$ piles for some $$$i$$$. All piles are distinguishable; there are $$$N^K$$$ different configurations.
You and Mike will play a game with the piles. You and Mike alternately do the following operation, with you going first.
The player who cannot make a valid move loses. Assuming both players play optimally, count the number of initial configurations that result in your loss, modulo $$$998244353$$$.
The first line contains integers $$$N$$$ ($$$1 \leq N \leq 100$$$) and $$$K$$$ ($$$1 \leq K \leq 10^{18}$$$).
The second line contains integers $$$A_1,A_2,\ldots,A_N$$$ ($$$1 \leq A_1 \lt A_2 \lt \cdots \lt A_N \leq 100$$$).
Print the answer.
1 7 1
1
5 100 2 3 5 7 9
842434993
Posted on a blog are $$$N+M$$$ harsh comments. You made $$$N$$$ comments, and the $$$i$$$-th of them has $$$A_i$$$ downvotes. The $$$i$$$-th of the other $$$M$$$ comments has $$$B_i$$$ downvotes.
Mike is going to delete the comments, one by one, by repeating the following operation:
Note that the choices in the operations are independent.
Find the expected number of operations Mike will do until he deletes all of your comments. The answer is a rational number, so print it modulo $$$998244353$$$ as usual. We can prove that such representation is always possible under the constraints of this problem.
The first line contains integers $$$N$$$ and $$$M$$$ ($$$1 \leq N,M \leq 100$$$).
The second line contains integers $$$A_1,A_2,\ldots,A_N$$$ ($$$1 \leq A_i \leq 100$$$).
The third line contains integers $$$B_1,B_2,\ldots,B_M$$$ ($$$1 \leq B_i$$$, $$$\sum_{1 \leq i \leq N} A_i + \sum_{1 \leq i \leq M} B_i \lt 998244353$$$).
Print the answer.
1 2 1 1 1
2
1 1 2 1
332748119
3 3 2 3 5 7 11 900000000
636512475
You are given an integer $$$N$$$ and an integer sequence $$$X$$$ of length $$$M$$$. Count, modulo $$$998244353$$$, the number of permutations $$$P = (P_1,P_2,\ldots,P_N)$$$ of $$$(1,2,\ldots,N)$$$ that satisfy the following condition:
The first line contains integers $$$N$$$ ($$$1 \leq N \leq 250000$$$) and $$$M$$$ ($$$1 \leq M \leq N$$$).
The second line contains integers $$$X_1,X_2,\ldots,X_M$$$ ($$$1 \leq X_i \leq N$$$, $$$X_i \neq X_j$$$ for all $$$i \neq j$$$).
Print the answer.
3 2 1 2
3
10 5 2 7 8 3 6
0
5 5 1 2 3 4 5
1
This problem might be well-known in some countries, but how do other countries learn about such problems if nobody poses them?
You are given a non-decreasing positive integer sequence $$$A = (A_1, A_2, \ldots, A_N)$$$ of length $$$N$$$. For each $$$k=0,1,2,\ldots,N$$$, count the number of non-decreasing non-negative integer sequences $$$x = (x_1, x_2, \ldots, x_N)$$$ of length $$$N$$$ that satisfy following conditions, modulo $$$998244353$$$:
The first line contains an integer $$$N$$$ ($$$1 \leq N \leq 250000$$$).
The second line contains $$$N$$$ integers $$$A_1,A_2,\ldots,A_N$$$ ($$$1 \leq A_1 \leq A_2 \leq \cdots \leq A_N \leq 250000$$$).
For each $$$k=0,1,2,\ldots,N$$$, print the answer.
3 1 2 3
5 5 3 1
4 3 3 3 3
15 10 6 3 1
5 10 10 11 11 12
3982 1285 352 77 12 1