比赛 NOIP2008集训模拟5 评测结果 WWWTTTTTTA
题目名称 数星星 最终得分 10
用户昵称 bing 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-11-14 11:17:21
显示代码纯文本
program bing;
var
 f1,f2:text;
 n,max:integer;
 x,y:array[1..1000] of integer;
 a:array[1..1000,1..1000] of integer;
 b:array[1..1000,1..1000] of real;
procedure init;
var
 i,j:integer;
begin
 assign(f1,'stars.in');reset(f1);
 assign(F2,'stars.out');rewrite(F2);
 readln(f1,n);
 for i:=1 to n do
  readln(f1,x[i],y[i]);
 fillchar(a,sizeof(a),0);
 for i:=1 to n do
 for j:=1 to n do b[i,j]:=0;
end;
procedure nb;
var
 i,j,k:integer;
 f:boolean;
 t:real;
begin
 for i:=1 to n do
 begin a[1,i]:=1;b[1,i]:=1001;end;
 for i:=1 to n-1 do
 begin
 a[2,i]:=2;
 if y[i]-y[i+1]<>0 then
 b[2,i]:=(x[i]-x[i+1])/(y[i]-y[i+1])
 else b[2,i]:=1002;
 end;
 for i:=3 to n do
 begin
  for j:=1 to n-i+1 do
  begin
   for k:=1 to i-1 do
   begin
    f:=false;
    if (k=1)or(i-k=1) then begin
                  if y[j]-y[j+k]<>0 then
                t:=(x[j]-x[j+k])/(y[j]-y[j+k])
               else t:=1002;
               if (k=1)then if (t=b[i-k,j+k]) then f:=true;
               if (i-k=1) then if (t=b[k,j]) then f:=true;
               end
    else if b[k,j]=b[i-k,j+k] then f:=true;
    if f then
   if (a[k,j]+a[i-k,j+k]>a[i,j]) then
    begin
     a[i,j]:=a[k,j]+a[i-k,j+k];
     if b[k,j]<>1001 then b[i,j]:=b[k,j]
     else b[i,j]:=b[i-k,j+k];
    end;
   end;
   if a[i,j]>max then max:=a[i,j];
  end;
 end;
end;
begin
 init;
 nb;
 write(f2,max);
 close(F1);close(f2);
end.