light oj 1095 组合数学

时间:2024-11-20 16:04:38
 #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <climits>
#include <queue>
#define ll long long using namespace std; const int MAX = ;
const ll MOD = 1e9+;
ll F[],C[][]; void init()
{
F[] = ;
F[] = ;
F[] = ;
for(int i = ; i <= ; i++)
F[i] = (i-)*(F[i-]+F[i-])%MOD; for(int i = ; i <= ; i++)
{
for(int j = ; j <= i; j++)
{
if(j == )
C[i][j] = ;
else
C[i][j] = (C[i-][j]+C[i-][j-])%MOD;
}
}
} void solve()
{
int n,m,k;
scanf("%d %d %d",&n,&m,&k);
ll ans = ;
for(int i = ; i <= n-m; i++)
{
ans += (C[n-m][i]*F[n-k-i]);
ans %= MOD;
}
ans *= C[m][k];
ans %= MOD;
printf("%lld\n",ans);
} int main(void)
{
init();
int t,cnt = ;
scanf("%d",&t);
while(t--)
{
printf("Case %d: ",++cnt);
solve();
}
return ;
}