Gardens

AtCoder
IDabc235_g
Time3000ms
Memory256MB
Difficulty
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: $N$ $A$ $B$ $C$ [samples]
Samples
Input #1
2 2 1 1
Output #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](https://img.atcoder.jp/ghi/30cbec3c4cc587889e3c37933da06c3f.png)
Input #2
2 0 0 0
Output #2
0

There may be no way to plant seedlings to satisfy the conditions.
Input #3
2 0 2 2
Output #3
9
Input #4
100 12 34 56
Output #4
769445780
Input #5
5000000 2521993 2967363 3802088
Output #5
264705492
API Response (JSON)
{
  "problem": {
    "name": "Gardens",
    "description": {
      "content": "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",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 3000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc235_g"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Takahashi has $A$ apple seedlings, $B$ banana seedlings, and $C$ cherry seedlings. Seedlings of the same kind cannot be distinguished.  \nHe will plant these seedlings in his $N$ gardens so that all of...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments