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

严重置疑本题

Posted by william1121 at 2006-03-18 14:19:45 on Problem 2366
我用的很普通的二分查找,修改10多次,提交10多次,一直是WA,自己写了一个平方的程序,然后比对,发现都是对的。
那位可不可以解释一下,难道这个题目专卡PASCAL?
要么,管理员帮个忙看一下

程序见下:
program eee;
{$R-}
var
  a:array[1..70010]of longint;
  p:boolean;
  i,j,k,l,n,m:longint;
procedure make(i:longint);
var
  l,r,x,mid:longint;
begin
  x:=10000-i;
  l:=1;r:=n;mid:=(l+r)shr 1;
  repeat
     if a[mid]=x then begin p:=true;exit;end
     else if x>a[mid] then
                       begin
                            l:=mid+1;
                            mid:=(l+r)shr 1;
                       end
     else begin
              r:=mid-1;
              mid:=(l+r) shr 1;
          end;
  until l>r;
end;
begin
  readln(n);p:=false;
  for i:=1 to  n do
    readln(a[i]);
  readln(m);
  for i:=1 to m do
    begin
        readln(j);
        make(j);
        if p then break;
    end;
  if p then writeln('YES')
       else writeln('NO');
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