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

Why I get WA??? What's wrong in my code!! Help me please!!
Posted by Vitaliy Surovyi 16 Sep 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!!!!!!!!!!!!!!!!!!!!
Posted by ACer 16 Sep 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?
Posted by Vitaliy Surovyi 16 Sep 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
Posted by ACer 17 Sep 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!!
Posted by ACer 17 Sep 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????
Posted by Vitaliy Surovyi 17 Sep 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????
Posted by GodZilla 17 Sep 2003 20:14
Mail Me and you'll get an answer !!!