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

<PASCAL> why wa?

Posted by Ocirlin at 2005-09-13 20:49:10 on Problem 1006
program pku1006;
var aa,nn:array[1..3] of integer;
    count,i,s,day:integer;
function euc(a,b:longint;var x,y:longint):longint;
 var t:longint;
 begin
  if b=0 then
    begin
     euc:=a;x:=1;y:=0;
    end
  else
    begin
     euc:=euc(b,a mod b,x,y);
     t:=x;x:=y;y:=t-(a div b)*y;
    end;
  end;
procedure china;
 var d,x,y,n,m,i,a:longint;
 begin
  n:=21252;
  a:=0;
  for i:=1 to 3 do begin
   m:=n div nn[i];
   d:=euc(nn[i],m,x,y);
   a:=a+m*((y*aa[i])mod n);
  end;
  while a<=0 do a:=a+n;
  while a>n do a:=a-n;
 writeln('Case ',count,': the next triple peak occurs in ',a-day,' days.');
       end;

begin
 nn[1]:=23;
 nn[2]:=28;
 nn[3]:=33;

 count:=0;
 repeat
  inc(count);
  readln(aa[1],aa[2],aa[3],day);
  s:=0;
  for i:=1 to 3 do s:=s+aa[i];
    if (s<>-3) and (day<>-1) then china;
 until s=-3;
end.


用的解模线形方程组的方法 谁知道为什么WA? 测试数据都对

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