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

## why wa?哪位大牛告诉我啊!!!!!

Posted by dinosaur at 2006-07-15 18:56:20 on Problem 2051
```var
s:string;
i,j,k,n,m:longint;
q,t:array [1..1000] of longint;
procedure swap(var a,b:longint);
var
temp:longint;
begin
temp:=a;
a:=b;
b:=temp;
end;
procedure sort(l,r:longint);
var
ff,tt,mid:longint;
begin
ff:=l;
tt:=r;
mid:=random(r-l)+l;
repeat
while (q[ff]<q[mid]) do ff:=ff+1;
while (q[tt]>q[mid]) do tt:=tt-1;
if ff<=tt then
begin
swap(t[ff],t[tt]);
swap(q[ff],q[tt]);
ff:=ff+1;
tt:=tt-1;
end;
until ff>tt;
if ff<r then sort(ff,r);
if l<tt then sort(l,tt);
end;
procedure main;
begin
m:=0;
for j:=1 to 10000000 do
for n:=1 to i do
begin
if (j mod t[n]=0) then
begin
writeln(q[n]);
m:=m+1;
end;
if m=k then exit;
end;
end;
begin
i:=1;
fillchar(q,sizeof(q),0);
fillchar(t,sizeof(t),0);
while (pos('#',s)=0) do
begin
j:=pos(' ',s);
while s[j]=' ' do j:=j+1;
while s[j]<>' ' do
begin
q[i]:=q[i]*10+ord(s[j])-48;
j:=j+1;
end;
j:=j+1;
while (s[j]<>' ') and (j<=length(s)) do
begin
t[i]:=t[i]*10+ord(s[j])-48;
j:=j+1;
end;
i:=i+1;
end;
i:=i-1;
sort(1,i);
main;
end.
```

Followed by: