| ||||||||||
| 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 | |||||||||
1AC PASCALvar i,j,n,m,sum:integer;
a:array[1..100]of integer;
procedure sort(l,r: longint);
var
i,j,x,y: longint;
begin
i:=l;
j:=r;
x:=a[(l+r) div 2];
repeat
while a[i]<x do
inc(i);
while x<a[j] do
dec(j);
if not(i>j) then
begin
y:=a[i];
a[i]:=a[j];
a[j]:=y;
inc(i);
j:=j-1;
end;
until i>j;
if l<j then
sort(l,j);
if i<r then
sort(i,r);
end;
begin
read(n);
while n<>-1 do begin
fillchar(a,sizeof(a),0);
i:=1;
sum:=0;
while n<>0 do begin
a[i]:=n;
inc(i);
read(n);
end;
dec(i);
sort(1,i);
for j:=1 to i do
for m:=j to i do
if a[j]*2=a[m] then begin inc(sum);break; end;
writeln(sum);
read(n);
end;
end.
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator