Dominoes with separated squares
Tile a 2 × N board completely with 1 × 2 dominoes (placed either way) and 1 × 1 squares, so that no two 1 × 1 squares share a side. Count the tilings modulo 10^9 + 7.
Reported in: Infosys (SP / DSE · 22 Nov 2026) (memory-based)
Input
One line: N.
Output
The number of tilings modulo 10^9 + 7.
Constraints
1 ≤ N ≤ 10^5.
Example 1
Input:
1
Output:
1Example 2
Input:
2
Output:
2Example 3
Input:
3
Output:
5Example 4
Input:
5
Output:
24Hint: Fill the board column by column. Remember which cells of the next column are already covered by horizontal dominoes, and which rows of the current column hold a square: a square may not sit beside a square in the previous column, and the two cells of one column may not both be squares.