这是一道好题,要求每个三点圆覆盖的点数和

我们可以算四边形的贡献,四边形显然分成两种:凸四边形和凹四边形

显然,凹四边形的覆盖只可能是三个点组成三角形包含另一个点,所以贡献是1

凸四边形,其最小圆覆盖是以最长对角线为直径的

注意一个很重要的条件,四点不共圆,所以凸四边形的贡献是2

四边形总数是一定的,显然统计凹四边形更方便

穷举一个点作为原点,即求包含原点的三角形数目——转化为bzoj1914,解决了!

  1 uses math;
  2 type node=record
  3        x,y:longint;
  4      end;
  5 
  6 var c,b:array[0..1510] of node;
  7     tot,n,a,d:int64;
  8     i:longint;
  9 
 10 procedure swap(var a,b:node);
 11   var c:node;
 12   begin
 13     c:=a;
 14     a:=b;
 15     b:=c;
 16   end;
 17 
 18 function cross(a,b:node):double;
 19   begin
 20     exit(int64(a.x)*int64(b.y)-int64(a.y)*int64(b.x));
 21   end;
 22 
 23 function cmp(a,b:node):boolean;
 24   begin
 25     if (a.y>0) and (b.y<=0) then exit(true);
 26     if (b.y>0) and (a.y<=0) then exit(false);
 27     if cross(a,b)>0 then exit(true);
 28     exit(false);
 29   end;
 30 
 31 procedure sort(l,r:longint);
 32   var i,j:longint;
 33       x:node;
 34   begin
 35     i:=l;
 36     j:=r;
 37     x:=c[(l+r) shr 1];
 38     repeat
 39       while cmp(c[i],x) do inc(i);
 40       while cmp(x,c[j]) do dec(j);
 41       if not(i>j) then
 42       begin
 43         swap(c[i],c[j]);
 44         inc(i);
 45         dec(j);
 46       end;
 47     until i>j;
 48     if l<j then sort(l,j);
 49     if i<r then sort(i,r);
 50   end;
 51 
 52 function dis(a:node):double;
 53   begin
 54     exit(sqrt(sqr(a.x)+sqr(a.y)));
 55   end;
 56 
 57 function get(k:longint):int64;
 58   var i,s,t,r:longint;
 59       p:node;
 60   begin
 61     p:=b[k];
 62     t:=0;
 63     for i:=1 to n do
 64       if i<>k then
 65       begin
 66         inc(t);
 67         c[t].x:=b[i].x-p.x;
 68         c[t].y:=b[i].y-p.y;
 69       end;
 70     sort(1,t);
 71     get:=(n-1)*(n-2)*(n-3) div 6;
 72     r:=2;
 73     s:=0;
 74     for i:=1 to t do
 75     begin
 76       while cross(c[i],c[r])>=0 do
 77       begin
 78         r:=r mod t+1;
 79         inc(s);
 80         if r=i then break;
 81       end;
 82       get:=get-(s-1)*s div 2;
 83       dec(s);
 84     end;
 85   end;
 86 
 87 begin
 88   readln(n);
 89   if n=3 then
 90   begin
 91     writeln(3.00);
 92     halt;
 93   end;
 94   for i:=1 to n do
 95     readln(b[i].x,b[i].y);
 96   for i:=1 to n do
 97     a:=a+get(i);
 98 
 99   d:=n*(n-1)*(n-2)*(n-3) div 24-a;
100   tot:=(n-1)*(n-2)*n div 6;
101   writeln((a+2*d)/tot+3:0:6);
102 end.
View Code

 

posted on 2015-06-04 23:23  acphile  阅读(917)  评论(0编辑  收藏  举报