|
|
вернуться в форумWhy WA1? const y=1; type Tarray=array[-1..15002] of int64; var m,n,b,c,h,l,ans:int64;i,j:longint;d:Tarray;e:array[0..100002] of int64; function binp(a:Tarray;k,k1,k2:int64):int64; begin l:=k2; b:=(k1+k2) div 2; while a[b]<>k do begin if a[b]<k then begin k1:=b; b:=(k1+k2) div 2; if b=k1 then b:=b+1; if (b>l) or (a[b]>k) then exit; end; if a[b]>k then begin k2:=b; b:=(k1+k2) div 2; if b=k2 then b:=b-1; if (b<1) or (a[b]<k) then exit; end; end; if a[b]=k then binp:=1 else binp:=0; end; begin readln(n); For i:=1 to n do readln(d[i]); readln(m); For i:=1 to m do readln(e[i]); For i:=1 to m do ans:=ans+binp(d,e[i],y,n); write(ans); end. Edited by author 24.01.2014 15:24 |
|
|