4×n Tiling
Time limit2sMemory limit256 MB
Count the ways to tile a 4 by N board with 1 by 3 and 3 by 1 trominoes modulo 1000000007 for each test case.
- Level
Medium6 of 10
- Topics
- Dynamic programming, Bit manipulation
- Solved
- No attempts yet
Problem
The kingdom of icpc was once ruled by a very nasty king named Yubin.
Yubin owned a single carpet of size 4×n. He ordered his servants to cover the whole carpet with 3×1 tiles and 1×3 tiles, leaving no gap.
Help the servants and count the ways to cover a 4×n carpet with 3×1 tiles and 1×3 tiles. Tiles must not overlap and must not stick out of the carpet, and you may use as many tiles of each kind as you want.
Input
The first line contains the number of test cases . ()
Each of the next lines contains the width of the carpet, one per line. The height is always 4. ()
Output
For each test case, print the number of ways to cover the carpet modulo , one per line.