UVA 10910 Marks Distribution

题意:参考了大神的点击打开链接
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

int n,t,p,m;

long long C(int a ,int b){
    if(b-a < a)
        a=b-a;
    long long ans=1;
    for(int i = 1; i <= a; i++)
        ans = ans*(b-i+1)/i;
    return ans;
}

int main(){
    int Case;
    scanf("%d",&Case);
    while(Case--){
        scanf("%d%d%d",&n,&t,&p);
        m=t-n*p;
        n=n-1+m;
        printf("%lld\n",C(m,n));
    }
    return 0;
}


你可能感兴趣的:(UVA 10910 Marks Distribution)