Kings on a Chessboard
Time limit5sMemory limit256 MB
Count the ways to place k non-attacking kings on an x by y board and print each answer modulo 1,000,000,007.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Bit manipulation, Combinatorics
- Solved
- No attempts yet
Problem
You have a chessboard with rows and columns, and identical kings. Place all kings on the board so that no two of them attack each other. Two kings attack each other when they stand on adjacent squares horizontally, vertically, or diagonally. A square holds at most one king.
Write a program that counts the arrangements of the kings. The count can be very large, so report it modulo 1,000,000,007.
Input
The first line contains the number of test cases . Each of the next lines contains three integers , , and separated by one space.
Output
For each test case, print the number of arrangements modulo 1,000,000,007 on its own line, in the order the test cases are given.