atcoder#ABC240G. [ABC240G] Teleporting Takahashi
[ABC240G] Teleporting Takahashi
Score : points
Problem Statement
Takahashi is in the square in an infinite three-dimensional grid.
He can teleport between squares. From the square , he can move to , , , , , or in one teleport. (Note that he cannot stay in the square .)
Find the number of routes ending in the square after exactly teleports.
In other words, find the number of sequences of 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.
- .
- .
- for each .
Since the number can be enormous, print it modulo .
Constraints
- , , , and are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number modulo .
3 2 0 -1
3
There are three routes ending in the square after exactly 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)$
1 0 0 0
0
Note that exactly teleports should be performed, and they do not allow him to stay in the same position.
314 15 92 65
106580952
Be sure to print the number modulo .