Cod sursa(job #109417)

Utilizator zuzulicatilimpea razvan nicolae zuzulica Data 25 noiembrie 2007 11:00:20
Problema Ecuatie Scor 0
Compilator fpc Status done
Runda preONI 2008, Runda 1, Clasa a 9-a Marime 0.87 kb
 program p1;
 var fin,fout:text;
     a,b,c,d,x,y,z,o,i,j,k,a1,c1:integer;
     s:string;
     begin
     assign(fin,'ecuatie.in');
     reset(fin);
     read(fin,a,b,c,d);
     close(fin);
     if a<0 then
     a1:=a*(-1);
     if c<0 then
     c1:=c*(-1);
     for i:=((-1)*a1) to a1 do
     if a mod i=0 then
     begin
     x:=i;
     z:=a div i;
     end;
     for j:=((-1)*c1) to c1 do
     begin
     y:=j;
     o:=c div j;
     if (c mod j=0) and (y*z+x*o=c) then
     k:=k+1;
     if k=d then
     begin
     assign(fout,'ecuatie.out');
     rewrite(fout);
     write(fout,'(');
     str(x,s);
     write(fout,s);
     str(y,s);
     write(fout,s);
     write(fout,') ');
      write(fout,'(');
     str(z,s);
     write(fout,s);
     str(o,s);
     write(fout,s);
     write(fout,')');
     close(fout);
     end;
     end;
     end.