Please, check it. I have WA#3
Послано
Alexey 18 окт 2006 13:01
Can U give me some tricky tests to fail my program?
Thanks.
Var a:array[1..50,1..50] of Record ch,zn:longint; End;
b:array[1..50] of real;
n:integer;
fl:boolean;
ns:integer;
Procedure Input;
Var i,j:integer;
Begin
Readln(n); inc(n);
For j:=1 to n do Begin a[1,j].ch:=1; a[1,j].zn:=1; End; a[1,n].ch:=0;
For i:=2 to n do
Begin
For j:=1 to n-1 do Begin Read(a[i,j].ch); a[i,j].zn:=1; End;
a[i,n].ch:=-1; a[i,n].zn:=1;
Readln;
End;
b[1]:=1;
End;
Function Nod(a,b:longint):longint; Begin If b=0 then Nod:=a else Nod:=Nod(b,a mod b); End;
Procedure Run(ns:integer);
Var d,c,z,i,j:longint;
Procedure Cor(i:integer);
Var j:integer;
Begin
b[i]:=b[i]-(b[ns]*a[i,ns].ch/a[i,ns].zn);
For j:=n downto ns do
Begin
c:=a[i,j].ch*a[i,ns].zn*a[ns,j].zn-a[i,j].zn*a[i,ns].ch*a[ns,j].ch;
z:=a[i,j].zn*a[i,ns].zn*a[ns,j].zn;
a[i,j].ch:=c; a[i,j].zn:=z;
d:=Nod(a[i,j].ch,a[i,j].zn);
a[i,j].ch:=a[i,j].ch div d; a[i,j].zn:=a[i,j].zn div d;
End;
End;
Begin
b[ns]:=b[ns]*a[ns,ns].zn/a[ns,ns].ch;
For j:=n downto ns do
Begin
c:=a[ns,j].ch*a[ns,ns].zn; z:=a[ns,j].zn*a[ns,ns].ch;
a[ns,j].ch:=c; a[ns,j].zn:=z;
d:=Nod(a[ns,j].ch,a[ns,j].zn);
a[ns,j].ch:=a[ns,j].ch div d; a[ns,j].zn:=a[ns,j].zn div d;
End;
If fl then For i:=1 to ns-1 do Cor(i)
else For i:=ns+1 to n do Cor(i);
End;
Procedure Output;
Var i:integer;
Begin
For i:=1 to n-1 do Writeln(b[i]:0:8);
End;
BEGIN
Input;
For ns:=1 to n do Run(ns);
fl:=true;
For ns:=n downto 1 do Run(ns);
Output;
END.