2 by n Tiling
InterviewTime limit1sMemory limit256 MB
Count the ways to tile a 2 by n rectangle with 1 by 2 dominoes and print the count modulo 10007.
- Level
Easy3 of 10
- Topics
- Dynamic programming
- Solved
- No attempts yet
Problem
Write a program that counts the ways to fill a 2 by rectangle completely with 1 by 2 tiles and 2 by 1 tiles. Tiles may not overlap and may not stick out of the rectangle.
The picture below shows one way to fill a 2 by 5 rectangle.

Input
The first line contains . ()
Output
Print the number of ways to fill the 2 by rectangle, modulo , on the first line.