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

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

Why I get WA??? What's wrong in my code!! Help me please!!
Послано Vitaliy Surovyi 16 сен 2003 16:35
I use formula ((n+b)!/(b!*n!)) * ((n+a)!/(a!*n!))
This is my code :

{$N+}
Var
   D,D1 : Array [1..100] Of Byte;
   Res,Res1 : Extended;
   I,J,N,A,B,Max,T,T1 : Longint;
Begin
Read(N,A,B);
For I:=1 To N+B Do Begin Inc(T);D[T]:=I;End;
For I:=1 To N+A Do Begin Inc(T);D[T]:=I;End;

For I:=1 To B Do Begin Inc(T1);D1[T1]:=I;End;
For I:=1 To A Do Begin Inc(T1);D1[T1]:=I;End;
For I:=1 To N Do Begin Inc(T1);D1[T1]:=I;End;
For I:=1 To N Do Begin Inc(T1);D1[T1]:=I;End;

For I:=1 To 2*N+A+B Do
For J:=1 To 2*N+A+B Do
If D[I]=D1[J] Then Begin D[I]:=0;D1[J]:=0;Break;End;

For I:=1 To 2*N+A+B Do
For J:=1 To 2*N+A+B Do
If (D1[J]<>0) And (D[I]<>0) Then
If D[I] Mod D1[J] = 0 Then Begin D[I]:=D[I] Div D1[J];D1[J]:=0;End;

Res:=1;
For I:=1 To 2*N+A+B Do If D[I]<>0 Then Res:=Res*D[I];

Res1:=1;
For I:=1 To 2*N+A+B Do If D1[I]<>0 Then Res1:=Res1*D1[I];

Writeln(Res/Res1:0:0);
End.
Re: don't use extended!!!!!!!!!!!!!!!!!!!!
Послано ACer 16 сен 2003 18:54
>
> I use formula ((n+b)!/(b!*n!)) * ((n+a)!/(a!*n!))
> This is my code :
>
> {$N+}
> Var
>    D,D1 : Array [1..100] Of Byte;
>    Res,Res1 : Extended;
>    I,J,N,A,B,Max,T,T1 : Longint;
> Begin
> Read(N,A,B);
> For I:=1 To N+B Do Begin Inc(T);D[T]:=I;End;
> For I:=1 To N+A Do Begin Inc(T);D[T]:=I;End;
>
> For I:=1 To B Do Begin Inc(T1);D1[T1]:=I;End;
> For I:=1 To A Do Begin Inc(T1);D1[T1]:=I;End;
> For I:=1 To N Do Begin Inc(T1);D1[T1]:=I;End;
> For I:=1 To N Do Begin Inc(T1);D1[T1]:=I;End;
>
> For I:=1 To 2*N+A+B Do
> For J:=1 To 2*N+A+B Do
> If D[I]=D1[J] Then Begin D[I]:=0;D1[J]:=0;Break;End;
>
> For I:=1 To 2*N+A+B Do
> For J:=1 To 2*N+A+B Do
> If (D1[J]<>0) And (D[I]<>0) Then
> If D[I] Mod D1[J] = 0 Then Begin D[I]:=D[I] Div D1[J];D1[J]:=0;End;
>
> Res:=1;
> For I:=1 To 2*N+A+B Do If D[I]<>0 Then Res:=Res*D[I];
>
> Res1:=1;
> For I:=1 To 2*N+A+B Do If D1[I]<>0 Then Res1:=Res1*D1[I];
>
> Writeln(Res/Res1:0:0);
> End.
But in test 20 15 15 number is very large?
Послано Vitaliy Surovyi 16 сен 2003 19:44
> >
> > I use formula ((n+b)!/(b!*n!)) * ((n+a)!/(a!*n!))
> > This is my code :
> >
> > {$N+}
> > Var
> >    D,D1 : Array [1..100] Of Byte;
> >    Res,Res1 : Extended;
> >    I,J,N,A,B,Max,T,T1 : Longint;
> > Begin
> > Read(N,A,B);
> > For I:=1 To N+B Do Begin Inc(T);D[T]:=I;End;
> > For I:=1 To N+A Do Begin Inc(T);D[T]:=I;End;
> >
> > For I:=1 To B Do Begin Inc(T1);D1[T1]:=I;End;
> > For I:=1 To A Do Begin Inc(T1);D1[T1]:=I;End;
> > For I:=1 To N Do Begin Inc(T1);D1[T1]:=I;End;
> > For I:=1 To N Do Begin Inc(T1);D1[T1]:=I;End;
> >
> > For I:=1 To 2*N+A+B Do
> > For J:=1 To 2*N+A+B Do
> > If D[I]=D1[J] Then Begin D[I]:=0;D1[J]:=0;Break;End;
> >
> > For I:=1 To 2*N+A+B Do
> > For J:=1 To 2*N+A+B Do
> > If (D1[J]<>0) And (D[I]<>0) Then
> > If D[I] Mod D1[J] = 0 Then Begin D[I]:=D[I] Div D1[J];D1
[J]:=0;End;
> >
> > Res:=1;
> > For I:=1 To 2*N+A+B Do If D[I]<>0 Then Res:=Res*D[I];
> >
> > Res1:=1;
> > For I:=1 To 2*N+A+B Do If D1[I]<>0 Then Res1:=Res1*D1[I];
> >
> > Writeln(Res/Res1:0:0);
> > End.
Re: It's not very large,only 20 digits.but you mustn't,or got WA
Послано ACer 17 сен 2003 17:43
> > >
> > > I use formula ((n+b)!/(b!*n!)) * ((n+a)!/(a!*n!))
> > > This is my code :
> > >
> > > {$N+}
> > > Var
> > >    D,D1 : Array [1..100] Of Byte;
> > >    Res,Res1 : Extended;
> > >    I,J,N,A,B,Max,T,T1 : Longint;
> > > Begin
> > > Read(N,A,B);
> > > For I:=1 To N+B Do Begin Inc(T);D[T]:=I;End;
> > > For I:=1 To N+A Do Begin Inc(T);D[T]:=I;End;
> > >
> > > For I:=1 To B Do Begin Inc(T1);D1[T1]:=I;End;
> > > For I:=1 To A Do Begin Inc(T1);D1[T1]:=I;End;
> > > For I:=1 To N Do Begin Inc(T1);D1[T1]:=I;End;
> > > For I:=1 To N Do Begin Inc(T1);D1[T1]:=I;End;
> > >
> > > For I:=1 To 2*N+A+B Do
> > > For J:=1 To 2*N+A+B Do
> > > If D[I]=D1[J] Then Begin D[I]:=0;D1[J]:=0;Break;End;
> > >
> > > For I:=1 To 2*N+A+B Do
> > > For J:=1 To 2*N+A+B Do
> > > If (D1[J]<>0) And (D[I]<>0) Then
> > > If D[I] Mod D1[J] = 0 Then Begin D[I]:=D[I] Div D1[J];D1
> [J]:=0;End;
> > >
> > > Res:=1;
> > > For I:=1 To 2*N+A+B Do If D[I]<>0 Then Res:=Res*D[I];
> > >
> > > Res1:=1;
> > > For I:=1 To 2*N+A+B Do If D1[I]<>0 Then Res1:=Res1*D1[I];
> > >
> > > Writeln(Res/Res1:0:0);
> > > End.
Re: this is WHY the AC problems in discuss always get WA!!
Послано ACer 17 сен 2003 17:45
> > >
> > > I use formula ((n+b)!/(b!*n!)) * ((n+a)!/(a!*n!))
> > > This is my code :
> > >
> > > {$N+}
> > > Var
> > >    D,D1 : Array [1..100] Of Byte;
> > >    Res,Res1 : Extended;
> > >    I,J,N,A,B,Max,T,T1 : Longint;
> > > Begin
> > > Read(N,A,B);
> > > For I:=1 To N+B Do Begin Inc(T);D[T]:=I;End;
> > > For I:=1 To N+A Do Begin Inc(T);D[T]:=I;End;
> > >
> > > For I:=1 To B Do Begin Inc(T1);D1[T1]:=I;End;
> > > For I:=1 To A Do Begin Inc(T1);D1[T1]:=I;End;
> > > For I:=1 To N Do Begin Inc(T1);D1[T1]:=I;End;
> > > For I:=1 To N Do Begin Inc(T1);D1[T1]:=I;End;
> > >
> > > For I:=1 To 2*N+A+B Do
> > > For J:=1 To 2*N+A+B Do
> > > If D[I]=D1[J] Then Begin D[I]:=0;D1[J]:=0;Break;End;
> > >
> > > For I:=1 To 2*N+A+B Do
> > > For J:=1 To 2*N+A+B Do
> > > If (D1[J]<>0) And (D[I]<>0) Then
> > > If D[I] Mod D1[J] = 0 Then Begin D[I]:=D[I] Div D1[J];D1
> [J]:=0;End;
> > >
> > > Res:=1;
> > > For I:=1 To 2*N+A+B Do If D[I]<>0 Then Res:=Res*D[I];
> > >
> > > Res1:=1;
> > > For I:=1 To 2*N+A+B Do If D1[I]<>0 Then Res1:=Res1*D1[I];
> > >
> > > Writeln(Res/Res1:0:0);
> > > End.
But what type I must use????
Послано Vitaliy Surovyi 17 сен 2003 18:54
> > > >
> > > > I use formula ((n+b)!/(b!*n!)) * ((n+a)!/(a!*n!))
> > > > This is my code :
> > > >
> > > > {$N+}
> > > > Var
> > > >    D,D1 : Array [1..100] Of Byte;
> > > >    Res,Res1 : Extended;
> > > >    I,J,N,A,B,Max,T,T1 : Longint;
> > > > Begin
> > > > Read(N,A,B);
> > > > For I:=1 To N+B Do Begin Inc(T);D[T]:=I;End;
> > > > For I:=1 To N+A Do Begin Inc(T);D[T]:=I;End;
> > > >
> > > > For I:=1 To B Do Begin Inc(T1);D1[T1]:=I;End;
> > > > For I:=1 To A Do Begin Inc(T1);D1[T1]:=I;End;
> > > > For I:=1 To N Do Begin Inc(T1);D1[T1]:=I;End;
> > > > For I:=1 To N Do Begin Inc(T1);D1[T1]:=I;End;
> > > >
> > > > For I:=1 To 2*N+A+B Do
> > > > For J:=1 To 2*N+A+B Do
> > > > If D[I]=D1[J] Then Begin D[I]:=0;D1[J]:=0;Break;End;
> > > >
> > > > For I:=1 To 2*N+A+B Do
> > > > For J:=1 To 2*N+A+B Do
> > > > If (D1[J]<>0) And (D[I]<>0) Then
> > > > If D[I] Mod D1[J] = 0 Then Begin D[I]:=D[I] Div D1[J];D1
> > [J]:=0;End;
> > > >
> > > > Res:=1;
> > > > For I:=1 To 2*N+A+B Do If D[I]<>0 Then Res:=Res*D[I];
> > > >
> > > > Res1:=1;
> > > > For I:=1 To 2*N+A+B Do If D1[I]<>0 Then Res1:=Res1*D1[I];
> > > >
> > > > Writeln(Res/Res1:0:0);
> > > > End.
Re: But what type I must use????
Послано GodZilla 17 сен 2003 20:14
Mail Me and you'll get an answer !!!