Find k stones in the n * m matrix, and the first column in the last row must have stones in the last column.
Consider the opposite side to find all the situations where the subtraction is not satisfied
A total of four sets of A (no stones in the first line) B (no stones in the last line) C (no stones in the first column) D (no stones in the last column)
Minus one set plus two sets minus three sets plus four sets
# Include
# Include
Const int maxn = 510; const int mod = 1000007; int C [maxn] [maxn]; int main () {C [0] [0] = 1; for (int I = 0; I <= 500; I ++) {C [I] [0] = C [I] [I] = 1; for (int j = 1; j <I; j ++) C [I] [j] = (C [I-1] [j] + C [I-1] [J-1]) % mod;} int T; int cas = 1; scanf ("% d", & T); while (T --) {int n, m, k, sum = 0; scanf ("% d", & n, & m, & k); for (int s = 0; s <16; s ++) {int B = 0, r = n, c = m; if (s & 1) {r --; B ++;} if (s & 2) {r --; B ++;} if (s & 4) {c --; B ++;} if (s & 8) {c --; B ++ ;} if (B & 1) sum = (sum-C [r * c] [k]) % mod + mod) % mod; elsesum = (sum + C [r * c] [k]) % mod;} printf ("Case % d: % d \ n", cas ++, sum );} return 0 ;}