HDU/2049-i/main.c
Saturneric 0525ffad24 Add.
2020-09-01 00:48:58 +08:00

22 lines
413 B
C

#include<stdio.h>
unsigned long long sum[21],f[21];
int main()
{
int i,t,n,m;
f[0]=0;f[1]=0;f[2]=1;
sum[0]=1;sum[1]=1;
for(i=2;i<=20;i++)
{
sum[i]=sum[i-1]*i;
if(i>=3)
f[i]=(i-1)*(f[i-1]+f[i-2]);
}
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&m);
printf("%llu\n",sum[n]/sum[m]/sum[n-m]*f[m]);
}
return 0;
}