Blocks 4
Time limit1sMemory limit256 MB
Count the tilings of an N by M rectangle using blocks of size k by N (rotatable) for k from 1 to N, modulo 1999, where M can be as large as 1e10.
- Level
Hard8 of 10
- Topics
- Dynamic programming, Math, Combinatorics, Matrix
- Solved
- No attempts yet
Problem
You want to fill a rectangle with blocks of several sizes. You have an unlimited supply of blocks, blocks, ..., blocks. A block may be turned by 90 degrees, so a block can be placed as rows by columns, or as rows by columns.
Count the ways to fill a rectangle of rows and columns with no gap and no overlap. Blocks of the same size are not distinguished, so two fillings are the same when the filled shape is the same. The count grows large, so print it modulo .
Input
The first line contains and , separated by a single space. (, )
Output
Print the number of ways to fill the rectangle, modulo .