Tiling a 2 by N wall
Time limit2sMemory limit512 MB
Count the ways to tile a 2 by N wall with 2x1, 1x2, and 1x1 tiles, modulo 1e9+7.
- Level
Medium5 of 10
- Topics
- Dynamic programming, Combinatorics
- Solved
- No attempts yet
Problem
You are given a wall of size . Fill the wall completely with tiles of size , and . Tiles must not overlap, no tile may stick out of the wall, and each size may be used any number of times.
Count the ways to fill the wall. Two ways are different when some cell is covered by a different tile.
Input
The first line contains an integer . ()
Output
Print the number of ways to fill the wall, taken modulo , on the first line.