标签:style blog class c code tar
#include <stdio.h> #include <string.h> const long long MOD = 1000000007; const int N = 1005; int t, n, m, k; long long dp[N], C[N][N]; void init() { dp[0] = 1; dp[1] = 0; dp[2] = 1; for (int i = 3; i <= 1000; i++) dp[i] = (i - 1) * ((dp[i - 2] + dp[i - 1]) % MOD) % MOD; for (int i = 0; i <= 1000; i++) { C[i][0] = C[i][i] = 1; for (int j = 1; j < i; j++) { C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD; } } } int main() { int cas = 0; init(); scanf("%d", &t); while (t--) { scanf("%d%d%d", &n, &m, &k); long long ans = 0; for (int i = 0; i <= n - m; i++) ans = (ans + C[n - m][i] * dp[n - k - i] % MOD) % MOD; printf("Case %d: %lld\n", ++cas, ans * C[m][k] % MOD); } return 0; }
UVA 11481 - Arrange the Numbers(组合数学),布布扣,bubuko.com
UVA 11481 - Arrange the Numbers(组合数学)
标签:style blog class c code tar
原文地址:http://blog.csdn.net/accelerator_/article/details/26170027