本文共 904 字,大约阅读时间需要 3 分钟。
22 23 2
13
#includeusing namespace std;_int64 dp[55];_int64 factor[21];int N,M;_int64 jie(int n){ if(n==1)return 1; if(factor[n])return factor[n]; factor[n]=n*jie(n-1); return factor[n];}int main(){ freopen("C:\\in.txt","r",stdin); memset(factor,0,sizeof(factor)); dp[1]=0; dp[2]=1; for(int i=3;i<21;i++) dp[i]=(i-1)*(dp[i-1]+dp[i-2]); jie(20); factor[0]=1; factor[1]=1; int C; scanf("%d",&C); while(C--){ scanf("%d %d",&N,&M); printf("%I64d\n",factor[N]/factor[N-M]/factor[M]*dp[M]); } return 0;}
转载地址:http://sdvvi.baihongyu.com/