Codeforces Beta Round #95 (Div. 2)

C. The World is a Theatre
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

<p< p=""><p< p="">
Input
<p< p="">

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

<p< p=""><p< p="">
Output
<p< p="">

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.

<p< p=""><p< p="">
Sample test(s)
<p< p=""><p< p="">
input
5 2 5
output
10
input
4 3 5
output
3


#include<iostream>
using namespace std;

__int64 c ( int n, int x )
{
    __int64 sum = 1;
    for ( int i = n, j = 1; i > x; i--, j++ )
        sum = sum * i / j;
    return sum;
}

int main()
{
    int b, g, t;
    __int64 sum = 0;
    cin >> b >> g >> t;
    for ( int i = max(4,t-g) ; i <= b && i <= t - 1; i++ )
        sum += c(b,i) * c(g,t-i);
    cout << sum << endl;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值