atcoder#TENKA12019F. Banned X
Banned X
Score : points
Problem Statement
Find the number, modulo , of sequences of length consisting of , and such that none of their contiguous subsequences totals to .
Constraints
- and are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number, modulo , of sequences that satisfy the condition.
3 3
14
sequences satisfy the condition: $(0,0,0),(0,0,1),(0,0,2),(0,1,0),(0,1,1),(0,2,0),(0,2,2),(1,0,0),(1,0,1),(1,1,0),(2,0,0),(2,0,2),(2,2,0)$ and .
8 6
1179
10 1
1024
9 13
18402
314 159
459765451