16,746
社区成员




function GetResult(const A, B, C: Integer; var x, y: Integer): Integer;
var
z, t, iy : Integer;
begin
t := A - B;
// z = y-x
for z:=1 to A do
begin
y := Trunc((z*A-C)/t);
for iy:=Max(y, z+1) to Trunc((z*A+C)/t) do
begin
x := iy - z;
Result := A*x - B*iy;
if((Result<=C)and(Result>=-C))then
begin
y := iy;
Exit;
end;
end;
end;
Result := -1;
end;