Ural 1114(49/600)

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 one line with three integers N, A and B separated by space.
Output
The result of your program must be an integer written on the only line of output.
Example
input output
2 1 1
9

可重复组合
说的就是有n个箱子放m个求必须放大于0个随便放有几种放法
就是从n+m-1里选n-1
这个是n+m选n是因为可以不放相当于有n+1个箱子

#include
using namespace std;
const unsigned long long maxn=50;
unsigned long long c[maxn][maxn];
void cinit()
{
    for(unsigned long long i=0; i0]=c[i][i]=1;
        for(unsigned long long j=1; j1][j]+c[i-1][j-1]);
    }
}
unsigned long long n,m,k;
main()
{
    cinit();
    cin>>n>>m>>k;
    unsigned long long aa=c[n+m][n],bb=c[n+k][n];
    cout<

你可能感兴趣的:(ACM练习,数学)