var
a,b,c,x,y,gcd:longint;
function getroot(a,b,c:longint;varx,y,gcd:longint):boolean;
var
tx,ty:longint;{记得设一个临时存下一层递归的变量}
begin
if b=0 then
if c mod a=0 then
begin
gcd:=a;
x:=c div a;
y:=0;
getroot:=true;
end
elsegetroot:=false
else
if getroot(b,a modb,c,tx,ty,gcd) then
begin
x:=ty;
y:=tx-(a div b)*ty;
getroot:=true;
end
else
getroot:=false;
end;
begin
read(a,b,c);
if getroot(a,b,c,x,y,gcd) then writeln(x,'',y);
end.
求不定方程初始解{ax+by=c,a,b,c∈Z…
最新推荐文章于 2025-09-21 19:05:25 发布
本文介绍了一种用于解决二次方程的算法,通过递归的方式计算根的值,确保了计算过程的准确性和效率。算法的核心在于合理利用递归特性,减少不必要的计算步骤,从而提高求解速度。

2471

被折叠的 条评论
为什么被折叠?



