|
|
вернуться в форумcombinatoric solution, which works(already:)) #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 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 Why do you think so? Re: combinatoric solution, which doesn't work(yet:)) - help me, plz Послано DNS 26 июл 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 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:)) Послано Leonid 26 окт 2013 13:03 This problem has a much easier(to understand) dp solution. |
|
|