AtCoder Beginner Contest 240
G
Teleporting Takahashi
AtCoder
⌀ 2462
原题
← Ex→
翻译中…

Problem Statement

翻译中…

Takahashi is in the square $(0, 0, 0)$ in an infinite three-dimensional grid.

翻译中…

He can teleport between squares. From the square $(x, y, z)$, he can move to $(x+1, y, z)$, $(x-1, y, z)$, $(x, y+1, z)$, $(x, y-1, z)$, $(x, y, z+1)$, or $(x, y, z-1)$ in one teleport. (Note that he cannot stay in the square $(x, y, z)$.)

翻译中…

Find the number of routes ending in the square $(X, Y, Z)$ after exactly $N$ teleports.

翻译中…

In other words, find the number of sequences of $N+1$ triples of integers $\big( (x_0, y_0, z_0), (x_1, y_1, z_1), (x_2, y_2, z_2), \ldots, (x_N, y_N, z_N)\big)$ that satisfy all three conditions below.

翻译中…
  • $(x_0, y_0, z_0) = (0, 0, 0)$.
  • $(x_N, y_N, z_N) = (X, Y, Z)$.
  • $|x_i-x_{i-1}| + |y_i-y_{i-1}| + |z_i-z_{i-1}| = 1$ for each $i = 1, 2, \ldots, N$.
翻译中…

Since the number can be enormous, print it modulo $998244353$.

翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 10^7$
  • $-10^7 \leq X, Y, Z \leq 10^7$
  • $N$, $X$, $Y$, and $Z$ are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N X Y Z

翻译中…

Output

翻译中…

Print the number modulo $998244353$.

翻译中…

样例

Input #1
3 2 0 -1
Output #1
3
There are three routes ending in the square $(2, 0, -1)$ after exactly $3$ teleports: - $(0, 0, 0) \rightarrow (1, 0, 0) \rightarrow (2, 0, 0) \rightarrow(2, 0, -1)$ - $(0, 0, 0) \rightarrow (1, 0, 0) \rightarrow (1, 0, -1) \rightarrow(2, 0, -1)$ - $(0, 0, 0) \rightarrow (0, 0, -1) \rightarrow (1, 0, -1) \rightarrow(2, 0, -1)$
Input #2
1 0 0 0
Output #2
0
Note that exactly $N$ teleports should be performed, and they do not allow him to stay in the same position.
Input #3
314 15 92 65
Output #3
106580952
Be sure to print the number modulo $998244353$.
题目信息
题号
abc240_g
时间限制
3 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。