#abc235g. G - Gardens
G - Gardens
Score : points
问题陈述
Takahashi 有 棵苹果树苗, 棵香蕉树苗和 棵樱桃树苗。同种类的树苗之间不可区分。 他将在他的 个花园中种植这些树苗,以满足所有以下条件。
- 每个花园中至少要种植一棵树苗。
- 同一个花园中不允许种植两棵或更多棵同种类的树苗。
- 不需要种植他所拥有的所有树苗。
有多少种方式可以种植树苗以满足这些条件?请在 取模后找到方案数。 两种方式被认为是不同的,当存在这样一个花园,在这两种方式中有不同组合的树苗被种植。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Takahashi has apple seedlings, banana seedlings, and cherry seedlings. Seedlings of the same kind cannot be distinguished.
He will plant these seedlings in his 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 .
Two ways are distinguished when there is a garden with different sets of seedlings planted in these two ways.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
2 2 1 1
Sample Output 1
21
As illustrated below, there are ways to plant seedlings to satisfy the conditions.
(The two frames arranged vertically are the gardens. stand for apple, banana, cherry, respectively.)
Sample Input 2
2 0 0 0
Sample Output 2
0
There may be no way to plant seedlings to satisfy the conditions.
Sample Input 3
2 0 2 2
Sample Output 3
9
Sample Input 4
100 12 34 56
Sample Output 4
769445780
Sample Input 5
5000000 2521993 2967363 3802088
Sample Output 5
264705492
update @ 2024/3/10 10:12:45