ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1114. Boxes

combinatoric solution, which works(already:))
Posted by jedimastex 23 Jun 2004 20:55
#include <iostream>

using namespace std;

unsigned __int64 c(unsigned __int64, unsigned __int64);

unsigned __int64 a,b,n,ans;

int main()
{
    cin >> n >> a >> b;
    ans=c(n+a,a)*c(n+b,b);
    cout << ans;
    return 0;
}

 unsigned __int64 c(unsigned __int64 l, unsigned __int64 k)
{
    unsigned __int64 i,r=1,d=l-k;
    for (i=1;i<=d;i++) {r*=(i+k); r/=i;}
    return r;
}





Edited by author 24.06.2004 19:00
Re: combinatoric solution, which doesn't work(yet:)) - help me, plz
Posted by Gheorghe Stefan 23 Jun 2004 21:17
There is another formula but if I write it I don't think it will really help you...
Re: combinatoric solution, which doesn't work(yet:)) - help me, plz
Posted by jedimastex 2 Jan 2006 16:07
Why do you think so?
Re: combinatoric solution, which doesn't work(yet:)) - help me, plz
Posted by DNS 26 Jul 2010 02:34
Interestingly

N 1 1 = (n+1)^2 and 1 a b when a=b  answer (a+1)^2;

5 1 1 = true answer 36 and 1 5 5  = 36

etc ^_^

Edited by author 26.07.2010 02:34

Edited by author 26.07.2010 02:34
Re: combinatoric solution, which doesn't work(yet:)) - help me, plz
Posted by Su Jiao 7 Jan 2012 21:47
because the answer = (how many ways you can put no more than A red balls into N boxes)*(how many ways you can put no more than B blue balls into N boxes)
and (how many ways you can put no more than A red balls into N boxes)=C(a+n,a)//it is like there are a+n stickes in order, and you pick up n sticks so the rest sticks are divided into n+1 parts,the last part is for the balls which is not put in the box,and the 1st to nth part is for box 1st to nth
and the same for (how many ways you can put no more than B blue balls into N boxes)
Re: combinatoric solution, which works(already:))
Posted by Leonid 26 Oct 2013 13:03
This problem has a much easier(to understand) dp solution.