标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 26788 Accepted Submission(s): 9813
#include<queue> #include<math.h> #include<stdio.h> #include<string.h> #include<string> #include<iostream> #include<algorithm> using namespace std; #define N 2005 #define INF 0x3f3f3f3f long long f[N],n,m; int Cmn(int m, int n) { if(m < n || n < 0) return 0; if(m == n || n == 0) return 1; return (Cmn(m-1, n-1) + Cmn(m-1, n)); } int main() { f[1]=0;f[2]=1; for(int i=3;i<25;i++) f[i]=(i-1)*(f[i-1]+f[i-2]); int T;cin>>T; while(T--) { scanf("%d%d",&n,&m); cout<<Cmn(n,m)*f[m]<<endl; } return 0; } /* */ //freopen("1.txt", "r", stdin); //freopen("2.txt", "w", stdout);
HDU 2049 不容易系列之(4)——考新郎 (递推,含Cmn公式)
标签:
原文地址:http://www.cnblogs.com/wmxl/p/4774660.html