Cod sursa(job #1962636)

Utilizator _Victor_Victor Ciobanu _Victor_ Data 11 aprilie 2017 22:03:11
Problema Algoritmul lui Euclid extins Scor 0
Compilator fpc Status done
Runda Arhiva educationala Marime 0.7 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;
function cmmdc (a,b:maxt;var x,y : maxt):maxt;
var c,x0,y0 : maxt;
begin
 if b = 0 then begin
  x:=1;
  y:=0;
  cmmdc := A;
  exit;
 end else
 c:= cmmdc(b,(a mod b),x0,y0);
 x:= y0;
 y:= x0 - (a div B) * y0;
 cmmdc:= c;
 exit;
end;
begin
//assign(f,'euclid3.in');
//assign(g,'euclid3.out');
//reset(f);
//rewrite(g);
readln(T);
for i:=1 to T do begin
 readln({f,}a,b,c);
 d:= cmmdc(a,b,x,y);
 if c mod d = 0 then begin
  writeln({g,}x*(c/d),' ',y*(c/D));
 end else begin
  writeln({g,}'0 0');
 end;
end;
//close(f);
//close(g);
end.