ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1114. Коробки

combinatoric solution, which works(already:))
Послано jedimastex 23 июн 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
Послано Gheorghe Stefan 23 июн 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
Послано jedimastex 2 янв 2006 16:07
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
Послано Su Jiao 7 янв 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:))
Послано Leonid 26 окт 2013 13:03
This problem has a much easier(to understand) dp solution.