同余式组编程
发布时间: 2023-10-10 18:24:48
‘壹’ pascal编程:同余方程
var a,b,x,y,k:longint;
function exgcd(a,b:longint; var x,y:longint):longint;
var t:longint;
begin
if b=0 then
begin x:=1;y:=0;exit(a);end;
exgcd:=exgcd(b,a mod b,x,y);
t:=x;
x:=y;
y:=t-(a div b)*y;
end;
begin
readln(a,b);
k:=exgcd(a,b,x,y);
writeln((x+b)mod b);
end.
求采纳谢谢
热点内容