Jump

AtCoder
IDfps_24_h
Time2000ms
Memory256MB
Difficulty
On a 2D coordinate plane, a piece is placed at $(0, 0)$. You may perform the following operation any number of times (including zero): * Choose an integer pair $(a, b)$ such that $0 \leq a \leq 1$, $0 \leq b$, and $(a, b) \neq (0, 0)$. * If the current position of the piece is $(x, y)$, move it to $(x+a, y+b)$. Find the number of operation sequences that result in the piece being at $(N, M)$ after all operations, and output the answer modulo $998244353$. ## Constraints * $1 \leq N \leq 2 \times 10^5$ * $1 \leq M \leq 2 \times 10^5$ * All input values are integers ## Input The input is given from standard input in the following format: $N$ $M$ [samples]
Samples
Input #1
2 1
Output #1
5

For each valid operation sequence, the visited coordinates are as follows (5 possibilities):

*   $(0, 0) \to (0, 1) \to (1, 1) \to (2, 1)$
*   $(0, 0) \to (1, 0) \to (1, 1) \to (2, 1)$
*   $(0, 0) \to (1, 0) \to (2, 0) \to (2, 1)$
*   $(0, 0) \to (1, 0) \to (2, 1)$
*   $(0, 0) \to (1, 1) \to (2, 1)$
Input #2
12345 67890
Output #2
824829859
API Response (JSON)
{
  "problem": {
    "name": "Jump",
    "description": {
      "content": "On a 2D coordinate plane, a piece is placed at $(0, 0)$.   You may perform the following operation any number of times (including zero): *   Choose an integer pair $(a, b)$ such that $0 \\leq a \\leq 1",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "fps_24_h"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "On a 2D coordinate plane, a piece is placed at $(0, 0)$.  \nYou may perform the following operation any number of times (including zero):\n\n*   Choose an integer pair $(a, b)$ such that $0 \\leq a \\leq 1...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments