Filling a rectangle with blocks
Time limit1sMemory limit256 MB
Count the ways to tile an N by M rectangle with rectangles of size k by N for any k, each rotatable, modulo 1999.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Combinatorics, Math
- Solved
- No attempts yet
Problem
You have an unlimited number of blocks of each size , , , . Use them to fill a rectangle of rows and columns with no gaps.
A block can be turned by . That is, a block can be placed as rows by columns, or as rows by columns. Blocks must not overlap and must not stick out of the rectangle.
Two fillings count as different if any cell is covered by a block of a different position or shape. Print the number of fillings modulo .
Input
The first line contains and , separated by a space. (, )
Output
Print the number of fillings modulo on one line.