var a,b,c,d,x,y,m,n,l,x1,y1:int64; function exgcd(a,b:int64;var x,y:int64):longint; var t:longint; begin if b=0 then begin exgcd:=a; x:=1;y:=0; end else begin exgcd:=exgcd(b,a mod b,x,y); t:=x; x:=y; y:=t-(a div b)*y; end; end; begin readln(x,y,m,n,l); if x=y then begin writeln('0');halt;end; c:=x-y; a:=n-m;b:=l; if a=0 then begin writeln('Impossible'); halt; end; d:=exgcd(a,b,x1,y1); if c mod d<>0 then begin writeln('Impossible'); halt; end; a:=a div d; b:=b div d; c:=c div d; d:=exgcd(a,b,x1,y1); x1:=x1 div d;y:=y1 div d; x1:=x1*c; if b>0 then begin if x1>0 then while x1-b>=0 do x1:=x1-b; if x1<0 then while x1<0 do x1:=x1+b; end else begin if x1>0 then while x1+b>0 do x1:=x1+b; if x1<0 then while x1<0 do x1:=x1-b; end; writeln(x1); end. 当遇到gcd(a,b)=-1 时。exgcd 算出来的x,y可以认为ax+by=-1