Pair of Sequences

AtCoder
IDagc069_e
Time8000ms
Memory256MB
Difficulty
You are given integers $N$, $M$, $X$, and $Y$. Find the number, modulo $998244353$, of pairs $(A, B)$ of sequences $A=(a_1,\ldots,a_N)$ and $B=(b_1,\ldots,b_N)$ that satisfy all of the following conditions: * $A = (a_1, \ldots, a_N)$ is a sequence of non-negative integers. * $B = (b_1, \ldots, b_N)$ is a subsequence of $(0, 1, \ldots, M - 1)$. * $\sum\limits_{i=1}^{N} a_i = X$. * $\sum\limits_{i=1}^{N} a_i b_i = Y$. ## Constraints * $1 \leq N \leq M \leq 2 \times 10^5$ * $1 \leq X, Y \leq 2 \times 10^5$ * All input values are integers. ## Input The input is given from Standard Input in the following format: $N$ $M$ $X$ $Y$ [samples]
Samples
Input #1
3 4 3 4
Output #1
5

Here are the five pairs $(A, B)$ satisfying the conditions:

*   $A = (0, 2, 1)$, $B = (0, 1, 2)$
*   $A = (1, 0, 2)$, $B = (0, 1, 2)$
*   $A = (1, 1, 1)$, $B = (0, 1, 3)$
*   $A = (1, 2, 0)$, $B = (0, 2, 3)$
*   $A = (2, 1, 0)$, $B = (1, 2, 3)$
Input #2
1 1 1 1
Output #2
0

There are no pairs $(A, B)$ satisfying the conditions.
Input #3
12345 67890 9876 54321
Output #3
150392014

Find the count modulo $998244353$.
API Response (JSON)
{
  "problem": {
    "name": "Pair of Sequences",
    "description": {
      "content": "You are given integers $N$, $M$, $X$, and $Y$. Find the number, modulo $998244353$, of pairs $(A, B)$ of sequences $A=(a_1,\\ldots,a_N)$ and $B=(b_1,\\ldots,b_N)$ that satisfy all of the following condi",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 8000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "agc069_e"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given integers $N$, $M$, $X$, and $Y$.\nFind the number, modulo $998244353$, of pairs $(A, B)$ of sequences $A=(a_1,\\ldots,a_N)$ and $B=(b_1,\\ldots,b_N)$ that satisfy all of the following condi...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments