求组合数

#include<iostream>
#include<ctime>
#define LL long long
#define MAXN 2000
using namespace std;

int cnt;
int f[MAXN][MAXN];



LL c(LL m,LL n){
    cnt++;
    return n==1?m:1.0*m/n*c(m-1,n-1);
}

//
//LL c(LL m,LL n){
//  if(m==0) return 0;
//  if(n==1) return m;
//  cnt++;
//  return c(m-1,n)+c(m-1,n-1);
//  
//}

//LL c(LL m,LL n){
//  if(f[m][n]) return f[m][n];
//  if(m==0) return 0;
//  if(n==1) return m;
//  cnt++;
//  return f[m][n]=c(m-1,n)+c(m-1,n-1);
//  
//}

int main(){
    cout<<c(100,10);
    cout<<endl<<cnt<<endl;
    cout<<(double)clock()/CLOCKS_PER_SEC;
    return 0;

}
posted @ 2018-01-05 14:30  Menteur_hxy  阅读(100)  评论(0编辑  收藏  举报