codeforces-#478B. Random Teams 排列组合


D - The World is a Theatre
Crawling in process... Crawling failed
Time Limit: 2000MS     Memory Limit: 262144KB     64bit IO Format: %I64d & %I64u

Description

There are n boys and m girls attending a theatre club. To set a play "The Big Bang Theory", they need to choose a group containing 

exactly t actors containing no less than 4 boys and no less than one girl. How many ways are there to choose a group? Of course, 

the variants that only differ in the composition of the troupe are considered different.

Perform all calculations in the 64-bit type: long long for С/С++, int64 for Delphi and long for Java.

Input

The only line of the input data contains three integers n, m, t (4 ≤ n ≤ 30, 1 ≤ m ≤ 30, 5 ≤ t ≤ n + m).

Output

Find the required number of ways.

Please do not use the %lld specificator to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specificator.

Sample Input

Input
5 2 5
Output
10
Input
4 3 5
Output
3
解析:简单的一道排列组合题。从n中拿不少与四个,从m中拿不少与一个,拿的总和为t。
 
    
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
long long solve(int a,int b)
{
    if(a>b)
    return 0;
    int temp=min(b-a,a);
    long long ans=1;
    for(int i=1;i<=temp;i++)
    {
        ans*=(b--);
        ans/=i;
    }
    return ans;
}
int main()
{
    int n,m,t;
    cin>>n>>m>>t;
    long long ans=0;
    for(int i=4;i<t;i++)
    {
        ans+=solve(i,n)*solve(t-i,m);
    }
    cout<<ans<<endl;
    return 0;
}


 
   
 
   
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值