Cod sursa(job #290542)

Utilizator mariuscris90giuroiu marius mariuscris90 Data 28 martie 2009 02:37:39
Problema Oz Scor 20
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.66 kb
{$n+}
program ozz;
type vect=array[1..10000] of extended;
var  t:boolean;
     v:vect;
     f,g:text;
     i,j,m,n,x,y:longint;
     z:extended;
begin
assign(f,'oz.in');assign(g,'oz.out');reset(f);rewrite(g);
readln(f,n,m);t:=true;
for i:=1 to n do
v[i]:=1;
for i:=1 to m do begin
readln(f,x,y,z);
if trunc(v[x]/z)*z<>v[x] then if v[x]*z<=2000000000 then v[x]:=v[x]*z
                                            else t:=false;
if trunc(v[y]/z)*z<>v[y] then if v[y]*z<=2000000000 then v[y]:=v[y]*z
                                            else t:=false;
end;
if t then for i:=1 to n do write(g,v[i]:0:0,' ')
     else write(g,-1);
close(f);close(g);end.