- 隐形的翅膀
- 2010-07-06 16:14:24 @
这是我同学的程序,为什么不加0.0000000001交上去直接AC
program P1237;
const gold:real=0.6180339887498949;
var n,i,j,t1,t2:longint;
a:array[1..30000] of longint;
min,k:real;
procedure qsort(q,w:longint);{快排}
var e,r,t,y:longint;
begin
e:=a[(q+w) div 2];
r:=q;
t:=w;
repeat
while a[r]e do dec(t);
if rt;
if rq then qsort(q,t);
end;
begin
readln(n);
for i:=1 to n do
read(a[i]);
qsort(1,n);{排序}
min:=9999999;
i:=1;j:=2;{开始遍历翅膀}
repeat
k:=a[i]/a[j]-gold;{算比例}
if abs(k)0 then inc(j) else inc(i);{如果前翅膀比后翅膀大于GOLD,换下一个翅膀(翅膀是递增的)}
while (a[j]=0) do inc(j);
until j>n;
writeln(a[t1]);
writeln(a[t2])
end.
1 条评论
-
ljlovest LV 9 @ 2010-07-07 13:59:02
**while (a[j]=0) do inc(j); **
while (a[j]=0) do inc(j);
这句话有了就可以了
- 1