比赛 20110414 评测结果 AATTTTTEEE
题目名称 数三角形 最终得分 20
用户昵称 wo shi 刘畅 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2011-04-14 09:11:52
显示代码纯文本
var
  n,i,j,k,ans:longint;
  x,y:array[0..100000]of double;
  g:array[0..2000,0..2000]of double;

procedure dis(i,j:longint);
begin
  g[i,j]:=sqrt(sqr(x[i]-x[j])+sqr(y[i]-y[j]))
end;

function halun(a,b,c:double):double;
var
  p:double;
begin
  p:=(a+b+c)/2;
  halun:=sqrt(p*(p-a)*(p-b)*(p-c));
end;

function yes(i,j,k:longint):boolean;
var
  a,b,c,sum,s1,s2,s3:double;
begin
  a:=g[i,j];
  b:=g[j,k];
  c:=g[k,i];

  sum:=halun(a,b,c);

  s1:=halun(c,g[i,0],g[k,0]);
  s2:=halun(a,g[i,0],g[j,0]);
  s3:=halun(b,g[j,0],g[k,0]);

  if abs(s1+s2+s3-sum)<=0.00001 then exit(true)
  else exit(false);
end;

begin
  assign(input,'tricount.in'); reset(input);
  assign(output,'tricount.out'); rewrite(output);
  readln(n);

  x[0]:=0;
  y[0]:=0;

  for i:=1 to n do
  begin
    readln(x[i],y[i]);
    dis(i,0);
  end;

  for i:=1 to n do
   for j:=1 to n do
   dis(i,j);

  ans:=0;
  for i:=1 to n do
   for j:=i+1 to n do
    for k:=j+1 to n do
    if yes(i,j,k) then inc(ans);

  writeln(ans);
  close(input);
  close(output);
end.