No.2409 Strange Werewolves
タグ : / 解いたユーザー数 153
作問者 : 👑
hamamu
👑 Problem Statement
There are $X$ humans and $Y$ wolves, and all humans and wolves are distinguishable from one another. A meeting between the humans and the wolves will now be held.
The meeting proceeds as follows.
- From among the meeting participants who have not yet been banished, choose $1$ human or $1$ wolf and banish them. Banished humans and wolves can no longer participate in the rest of the meeting.
- Repeat this until all members of either the humans or the wolves have been banished.
- The meeting ends as soon as all members of either the humans or the wolves have been banished.
When the meeting ended, $Z$ humans had not yet been banished and $W$ wolves had not yet been banished. Here, one of $Z$ and $W$ is $0$. Find the total number of ways the banishments could have occurred, modulo $998244353$.
Two ways of banishment are considered different if there exists some $i$ such that the human or wolf banished in the $i$-th banishment differs between them.
Constraints
- All input values are integers.
- $1 \leq X, Y \leq 3 \times 10^5$
- $0 \leq Z, W \leq 3 \times 10^5$
- $Z \leq X$
- $W \leq Y$
- $Z = 0$ or $W = 0$
- $(Z, W) \neq (0, 0)$
Input
The input is given from Standard Input in the following format.
$X$ $Y$ $Z$ $W$
Output
Print the answer.
Sample
Sample 1
Input
2 2 1 0
Output
8
For convenience, label the humans as Humans $1,2$ and the wolves as Wolves $1,2$. Then the following $8$ cases are possible.
- Banished in the order Human $1$ → Wolf $1$ → Wolf $2$.
- Banished in the order Human $1$ → Wolf $2$ → Wolf $1$.
- Banished in the order Human $2$ → Wolf $1$ → Wolf $2$.
- Banished in the order Human $2$ → Wolf $2$ → Wolf $1$.
- Banished in the order Wolf $1$ → Human $1$ → Wolf $2$.
- Banished in the order Wolf $1$ → Human $2$ → Wolf $2$.
- Banished in the order Wolf $2$ → Human $1$ → Wolf $1$.
- Banished in the order Wolf $2$ → Human $2$ → Wolf $1$.
Sample 2
Input
2013 8 12 0
Output
212512743
Print the remainder when divided by $998244353$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。