HDU2519(组合数计算)

HDU2519

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll C(ll n, ll m){
    ll c;
    if(n < m) return 0;
    else if(m == 0) return 1;
    else{
        c = 1;
        n = n - m + 1;
        for(int i = 1; i <= m; i++){
            c *= n++;
            c /= i;
        }
    }
    return c;
}
int main(){
#ifdef ONLINE_JUDGE
#else
    freopen("in.txt", "r", stdin);
#endif
    int t, n, m;
    scanf("%d", &t);
    while(t--){
        scanf("%d%d", &n, &m);
        printf("%lld\n", C(n, m));
    }
    return 0;
}

posted on 2019-01-21 08:20  坤sir  阅读(250)  评论(0编辑  收藏  举报

导航