传统题 3000ms 1024MiB

G - Gardens

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

G - Gardens

Score : $600$ points

Problem Statement

Takahashi has $A$ apple seedlings, $B$ banana seedlings, and $C$ cherry seedlings. Seedlings of the same kind cannot be distinguished.
He will plant these seedlings in his $N$ gardens so that all of the following conditions are satisfied.

  • At least one seedling must be planted in every garden.
  • It is not allowed to plant two or more seedlings of the same kind in the same garden.
  • It is not necessary to plant all seedlings he has.

How many ways are there to plant seedlings to satisfy the conditions? Find the count modulo $998244353$.
Two ways are distinguished when there is a garden with different sets of seedlings planted in these two ways.

Constraints

  • $1 \leq N \leq 5 \times 10^6$
  • $0 \leq A \leq N$
  • $0 \leq B \leq N$
  • $0 \leq C \leq N$
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN AA BB CC

Output

Print the answer.


2 2 1 1
21

As illustrated below, there are $21$ ways to plant seedlings to satisfy the conditions.
(The two frames arranged vertically are the gardens. $A, B, C$ stand for apple, banana, cherry, respectively.)

image


2 0 0 0
0

There may be no way to plant seedlings to satisfy the conditions.


2 0 2 2
9

100 12 34 56
769445780

5000000 2521993 2967363 3802088
264705492

2024春季入门组刷题营(十二)

未参加
状态
已结束
规则
IOI
题目
8
开始于
2024-6-2 13:00
结束于
2024-6-2 15:00
持续时间
2 小时
主持人
参赛人数
10