F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

chess

Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 244    Accepted Submission(s): 69


Problem Description
Given an $n*n$ chessboard where you want to place some chess kings and $k$ chess rooks. You have to find the number of ways that no two rooks attack each other, no two kings attack each other, no rooks attack kings. (But kings can attack rooks.)

Because the result may be very large, please print the result modulo $1000000007$.

P.S. Two rooks attack each other if and only if thay are on the same rows or same columns.
Two kings attack each other if and only if one is on the other's adjacent 8 cells (vertical, horizontal or diagonal).
A rook attack a king if and only if the king is on the same rows or the same columns as the rook.
 

Input
The first line contains an integer $T$(about 10),indicating the number of cases.
Each test case begins with two integers $n(1 \leq n \leq 15)$ and $k(0 \leq k \leq 15)$.
 

Output
For each case, output an integer means the answer mod $1000000007$.
 

Sample Input
5 1 0 1 1 2 0 2 1 2 2
 

Sample Output
2 1 5 8 2
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 11:58:39, Gzip enabled