LL exgcd(LL x,LL y){ printf("%lld %lld ",x,y); if (y==0){ xx=1;yy=0;return(x); } LL ret=exgcd(y,x%y); LL t=xx;xx=yy;yy=t-(x/y)*yy; return(ret); }
procedure exgcd(a,b:int64); var t:longint; begin if b=0 then begin x:=1;y:=0; exit; end else exgcd(b,a mod b); t:=x;x:=y;y:=t-(a div b)*y; end; function cfny(a:int64):int64; var b:longint; begin b:=zs; exgcd(a,b); cfny:= ((x mod zs)+zs) mod zs; end;