文章目錄
- Input
- Output
- Sample Input
- Sample Output
| Result |
TIME Limit |
MEMORY Limit |
Run Times |
AC Times |
JUDGE |
|
3s |
8192K |
178 |
42 |
Standard |
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
- */