Pagini recente » Cod sursa (job #1769050) | Istoria paginii runda/iconcurs8/clasament | Cod sursa (job #2630532) | Rating Tataru Alexandra (alexandratataru) | Cod sursa (job #1257952)
program fotbal;
var
b,z,k,n,x,y,zz:longint;
f1,f2:text;
function gcd(a,b:longint):longint;
begin
if b=0 then begin
gcd:=a;
x:=1; y:=0;
end else begin
gcd:=gcd(b,a mod b);
zz:=x;
x:=y;
y:=zz-(a div b)*x;
end;
end;
function inversmodular(a,n:longint):longint;
var d:longint;
begin
d:=gcd(n,a);
if y<0 then y:=y+((-y) div n+1)*n;
y:=y mod n;
inversmodular:=y;
end;
begin
assign (f1,'fotbal.in');
assign (f2,'fotbal.out');
reset (f1);
rewrite (f2);
readln (f1,b,z);
writeln (f2,inversmodular(b,z));
close (f1);
close (f2);
end.