Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

在网上找了CTU的数据过了,为什么在这测评会WA

Posted by 464271301 at 2013-03-17 16:47:10 on Problem 2115
贴下代码
var a,b,c,k,t,now,c1,x,y:int64;
    flag:boolean;
function gcd(a,b:int64):int64;
var n,m:longint;
begin
  if b=0 then
  begin x:=1;y:=0;exit(a);end;
  gcd:=gcd(b,a mod b);
  n:=x;m:=y;
  x:=m;y:=n-a div b*m;
end;
procedure main;
begin
  readln(a,b,c,k);
  if k=0 then
  begin flag:=false;exit;end;
  t:=1<<(k-1);t:=t<<1;
  now:=gcd(c,t);
  if (b-a) mod now<>0 then writeln('FOREVER') else
  begin
    c1:=(b-a) div now;t:=t div now;
    x:=(x*c1 mod t+t) mod t;
    writeln(x);
  end;
end;
begin
  flag:=true;
  while flag do main;
end.
求修正,谢谢!

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator