Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
我用的 数论算法,竟然 wrong answer ?!!!!1program pku1061; var x0,y0,m0,n0,l0:int64; x,y,b,d,a,n:int64; function extended_gcd(a1,b1:int64;var x1,y1:int64):int64; var t:int64; begin if b1 =0 then begin extended_gcd:=a1; x1:=1; y1:=0; end else begin extended_gcd:= extended_gcd(b1, a1 mod b1,x1,y1); t:=x1; x1:=y1; y1:= t- (a1 div b1)* y1 end; end; begin while not eof do begin readln(x0,y0,m0,n0,l0); { (n0-m0)*x - l0*y=x0-y0 } a:=n0-m0;n:=-l0;b:=x0-y0; d:=extended_gcd(a,n,x,y); if b mod d<>0 then writeln('Impossible') else begin writeln(x); x:=x*(b div d) mod n; if x>0 then writeln(x) else writeln(n+x); end; end; end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator