joj 2296 Boxes
2011-04-11 23:07
274 查看
Result | TIME Limit | MEMORY Limit | Run Times | AC Times | JUDGE |
---|---|---|---|---|---|
3s | 8192K | 178 | 42 | Standard |
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 1Sample 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
*/
相关文章推荐
- Peer-to-Peer(P2P) communication across middleboxes(English)
- JOJ ACM 1107
- Peer-to-Peer (P2P) communication across middleboxes 部分翻译 之 收集整理
- JOJ 1058 T9
- 《编程之美》之寻找发帖水王与JOJ 1069
- JOJ 1133 Domino Effect
- 分酒问题与JOJ 1200 Jugs
- JOJ 1182: Lotto
- uva 103 - Stacking Boxes
- joj 1177 The 3n + 1 problem
- JOJ2672 Hanoi Tower Once More
- joj1197(深搜,Sum it up)
- joj 2526: medic
- joj 2569: Musical Chairs (约瑟夫环 数学方法非迭代)
- joj2075
- joj 3760 JLUCPC 树状DP
- JOJ 2558 / HDU 2757 (Ocean Currents) 解题纠错
- joj2090
- joj 1805
- JOJ 2580 Welcome to JL2009