Why I get WA??? What's wrong in my code!! Help me please!! 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? > > > > 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???? > > > > > > > > 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???? Mail Me and you'll get an answer !!! |