Tiling a 3-by-N Wall
InterviewTime limit2sMemory limit128 MB
Count the number of ways to tile a 3-by-N wall using 2x1 dominoes, for N up to 30.
- Level
Medium4 of 10
- Topics
- Dynamic programming, Combinatorics
- Solved
- No attempts yet
Problem
There is a rectangular wall with height 3 and width . You want to cover the entire wall with domino tiles of size or .
Tiles must not overlap, and no tile may extend outside the wall. Find the number of different ways to tile the wall.
Input
The first line contains an integer .
Output
Print the number of ways to tile a wall.
Hint
The figure below shows one tiling of a wall.
