| 2025 ICPC Asia Taichung Regional Contest (Unrated, Online Mirror, ICPC Rules, Preferably Teams) |
|---|
| Finished |
In Taiwan, many mathematics teachers design board and card games to help students grasp difficult mathematical concepts. Recently, a particular card game has gone viral among elementary and middle school teachers because it effectively helps students understand the concepts of divisors and multiples, while also being highly engaging for both teachers and students.
The rules of the game are as follows. The teacher prepares $$$n$$$ distinct cards, labeled from $$$1$$$ to $$$n$$$. The $$$i$$$-th card has an integer value $$$a_i$$$ written on it, and the integers $$$a_1, a_2, \dots, a_n$$$ are in a strictly increasing order.
There are $$$m$$$ students labeled from $$$1$$$ to $$$m$$$ participating in the game. Before the game begins, each student receives a nonempty subset of the $$$n$$$ cards. No two students share any card, and at least one card remains undealt.
Let $$$k$$$ denote the number of undealt cards initially. The game consists of $$$k$$$ rounds. In each round, the following steps occur in order:
Each student follows the same strategy throughout the game:
Assuming that all students follow this strategy in every round, determine the expected number of cards that each student will own at the end of the game.
The first line contains two integers $$$n$$$ and $$$m$$$, representing the number of cards and the number of students, respectively.
The second line contains $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$, where $$$a_i$$$ is the integer on the $$$i$$$-th card.
The third line contains $$$n$$$ integers $$$b_1,b_2,\ldots,b_n$$$, where $$$b_i$$$ describes the ownership of the $$$i$$$-th card before the game begins: it is owned by the $$$b_i$$$-th student if $$$b_i \ne 0$$$, and is undealt otherwise.
Print $$$m$$$ numbers in a new line, where the $$$i$$$-th number represents the expected number of cards the $$$i$$$-th student will own at the end of the game.
It can be proven that each answer can be represented by a rational number $$$\frac{p}{q}$$$ where $$$q$$$ is not a multiple of $$$998244353$$$. Therefore, you are asked to print $$$p \times q^{-1}$$$ modulo $$$998244353$$$ for each number, where $$$q^{-1}$$$ means the multiplicative inverse of $$$q$$$ modulo $$$998244353$$$.
5 21 2 3 4 50 0 1 2 1
499122179 499122179
6 21 2 3 4 5 60 0 0 1 0 2
831870297 166374061
8 34 5 8 9 12 18 20 240 0 0 0 0 2 1 3
332748120 2 665496239
| Name |
|---|


