Blocks 3
Time limit1sMemory limit256 MB
Count the tilings of an N by M rectangle using blocks of size k by N for any k, allowing 90-degree rotation, modulo 1999.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Combinatorics, Math, Matrix
- Solved
- No attempts yet
Problem
You fill a rectangle completely with blocks. For each of the , , ..., blocks you have an unlimited supply.
Fill a rectangle of height and width with these blocks. Blocks must not overlap and must not stick out of the rectangle. A block may be rotated by 90 degrees, so a block can be placed as rows by columns, or as rows by columns.
Count the ways to fill the rectangle and print that count modulo 1999. Two ways are different when at least one cell is covered by a block sitting in a different place.
Input
The first line contains and , separated by a space. (, )
Output
Print the number of ways to fill the rectangle, modulo 1999.