您的位置:首页 > 其它

joj 2296 Boxes

2011-04-11 23:07 274 查看
ResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE

3s8192K17842Standard
N boxes are lined up in a sequence (1 <= N <= 20). You have A red balls and B blue balls (0 <= A <= 15, 0 <= B <= 15). The red balls (and the blue ones) are exactly the same. You can place the balls in the boxes. It is allowed to put in a box, balls of the two kinds, or only from one kind. You can also leave some of the boxes empty. It's not necessary to place all the balls in the boxes. Write a program, which finds the number of different ways to place the balls in the boxes in the described way.

Input

Input contains many lines, every line with three integeres N, A and B separated by space.

Output

The result of your program must be an integer writen on the only line of output.

Sample Input

2 1 1

Sample Output

9


/*

一道简单的组合数学题,公式是c(n,a)*c(n,b),但是题目涉及到的数字较大如果不用高精度就得是unsigned long long而比赛的时候我一直拿double做,在输入是20 15 15时答案是末尾6000的数明显不是c(20,15)^2这样的平方数,找不到错误原因。

*/

//ac代码

#include <cstdio>

#include <iostream>

#include <cmath>

using namespace std;

int main ()

{

unsigned long long n,a,b;

while (cin>>n>>a>>b)

{

unsigned long long aa=1,bb=1;

unsigned long long ans=1;

if(n)

{

for ( unsigned long long i=1; i<=a ; i++)

aa=(i+n)*aa/i;

}

if(n)

{

for (unsigned long long i=1 ; i<=b ; i++ )

bb=(i+n)*bb/i;

}

ans=bb*aa;

printf("%llu/n",ans);

}

return 0;

}

/*

2 1 1

2 2 2

20 15 15

*/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: