- 清帝之惑之康熙
- 2009-04-06 19:01:14 @
program project1;
Var
a1,b1,x,y,n,m,l,e,d,b,a,x1,y1:Int64;
Function extend_gcd(a,b:Int64;Var x,y:Int64):Int64;
Var
t:Int64;
Begin
IF b=0 then
Begin
extend_gcd:=a;
x:=1;y:=0;
End
Else
Begin
extend_gcd:=extend_gcd(b,a mod b,x,y);
t:=x; x:=y; y:=t-(a div b)*y;
End;
End;
begin
Readln(x,y,n,m,l);
IF n=m then Begin Writeln('Impossible'); Exit; End;
IF n>m then
Begin
b1:=((y-x)mod l+l)mod l;
a1:=(n-m)mod l;
End
Else Begin
a1:=(m-n)mod l;
b1:=((x-y)mod l+l)mod l;
End;
d:=extend_gcd(a1,l,x1,y1);
IF b1 mod d 0 then
Begin
Writeln('Impossible');
Exit;
End;
e:=x1*(b1 div d);
e:=e mod l;// -(e div l)*l;
While e0 do e:=e-l;
Writeln(e);
Readln(a1);
end.
最后一组数据过不去
0 条评论
目前还没有评论...