C. The World is a Theatre
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.
Examples
input
5 2 5
output
10
input
4 3 5
output
3
思路:在4个男生1个女生的基础上暴力求组合数;不好描述见代码;
#include<iostream> #include<cstdio> #include<cmath> #include<string> #include<queue> #include<algorithm> #include<stack> #include<cstring> #include<vector> #include<list> #include<set> #include<map> using namespace std; #define ll long long #define inf 2000000001 int scan() { int res = 0 , ch ; while( !( ( ch = getchar() ) >= '0' && ch <= '9' ) ) { if( ch == EOF ) return 1 << 30 ; } res = ch - '0' ; while( ( ch = getchar() ) >= '0' && ch <= '9' ) res = res * 10 + ( ch - '0' ) ; return res ; } ll combine1(ll n,ll m) //计算组合数C(n,m) { ll sum=1; //线性计算 for(ll i=1,j=n;i<=m;i++,j--) sum=sum*j/i; return sum; } int main() { ll x,y,z,i,t; scanf("%I64d%I64d%I64d",&x,&y,&z); int b=4,g=z-4; ll ans=0; for(i=4;i<=x;i++) { b=i; g=z-i; if(g>y||g<1)continue; ans+=combine1(x,b)*combine1(y,g); } cout<<ans<<endl; return 0; }