组合数模板

组合数的公式:

组合数模板_第1张图片

CodeForces 131 C.The World is a Theatre

题意:
这题是计算C(n,i)C(m,t-i)求和,其中i从max(4,t-m)到min(t-1,n)

#include
using namespace std;
typedef long long ll;
int n,m,t;
ll ans;
ll C(int n,int m){
    ll temp=1;
    for(int i=1;i<=m;i++){
        temp=temp*(n-m+i)/i;
    }
    return temp;
}
int main(){
    cin>>n>>m>>t;
    ans=0;
    for(int i=4;i<=n;i++){
        if(t-i<=m&&icout<return 0;
}

你可能感兴趣的:(组合数模板)