Cod sursa(job #1968433)

Utilizator _Victor_Victor Ciobanu _Victor_ Data 17 aprilie 2017 18:08:22
Problema Algoritmul lui Euclid extins Scor 0
Compilator fpc Status done
Runda Arhiva educationala Marime 0.64 kb
Program EuclidExt;
type maxt = -1000000000 .. 1000000000;
maxc = -2000000000 .. 2000000000;
var d,a,b,x,y : maxt;
c: maxc;
t,i: 0..100;
f,g : text;
procedure euclid (a,b:maxt;var d,x,y : maxt);
var x0,y0 : maxt;
begin
 if b = 0 then begin
  x:=1;
  y:=0;
  d := A;
 end else begin
  euclid(b,(a mod b),d,x0,y0);
  x:= y0;
  y:= x0 - (a div B) * y0;
 end;
end;
begin
assign(f,'euclid3.in');
assign(g,'euclid3.out');
reset(f);
rewrite(g);
readln(f,T);
for i:=1 to T do begin
 read(f,a,b,c);
 euclid(a,b,d,x,y);
 if c mod d = 0 then 
  writeln(g,x*(c/d),' ',y*(c/D))
   else 
  writeln(g,'0 0');
end;
close(f);
close(g);
end.