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

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

Показать все сообщения Спрятать все сообщения

Here is my solution:

#include <fstream.h>
#include <stdio.h>

int n,a,b;
long double x[21][16][16];
int main()
{
 cin>>n>>a>>b;

 {
  for(int ai=0; ai<=a; ai++)
   for(int bi=0; bi<=b; bi++)
    x[0][ai][bi] = 1;
 }

 for(int in=1; in<=n; in++)
  for(int ia=0; ia<=a; ia++)
   for(int ib=0; ib<=b; ib++)
 {
   long double xx = 0;
   for(int ai=0; ai<=ia; ai++)
    for(int bi=0; bi<=ib; bi++)
     xx += x[in-1][ia-ai][ib-bi];
   x[in][ia][ib] = xx;
 }

/* cout.setf(ios::fixed);
 cout.precision(0);
 cout<<x[n][a][b]<<endl;*/
 printf("%.0Lf\n",x[n][a][b]);
 return 0;
}
You cannot accept a solution with long double. I write one by myself,
and kept getting WA, even though I tested it with the tests from the
Bulgarian competition. It just doesn't work on Timus. You'll have to
use bignum  :(
> You cannot accept a solution with long double. I write one by
myself,
> and kept getting WA, even though I tested it with the tests from
the
> Bulgarian competition. It just doesn't work on Timus. You'll have
to
> use bignum  :(
U probably writing in Borland C++ where long double have 80-bit
precision, and timus uses MSVC 6.0 compiler where long double is
equal to double and is 64 bit. I had the same problem, and i've post
solution in Pascal, later in C++ with long nums.