bzoj1913: [Apio2010]signaling 信号覆盖
题解传送门
//Achen #include<algorithm> #include<iostream> #include<cstring> #include<cstdlib> #include<vector> #include<cstdio> #include<queue> #include<cmath> #define pi acos(-1) #define eps 1e-15 const int N=1e5+7; #define For(i,a,b) for(int i=(a);i<=(b);i++) #define Rep(i,a,b) for(int i=(a);i>=(b);i--) typedef long long LL; typedef double db; using namespace std; int n,cnt; LL c1,c2,tp; db a[N],ans; template<typename T>void read(T &x) { char ch=getchar(); x=0; T f=1; while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar(); if(ch=='-') f=-1,ch=getchar(); for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0'; x*=f; } struct pt { db x,y; }p[N]; LL C(int n,int m) { LL rs=1; Rep(i,n,n-m+1) rs*=i; For(i,1,m) rs/=i; return rs; } int main() { read(n); tp=C(n-1,3); For(i,1,n) scanf("%lf%lf",&p[i].x,&p[i].y); For(i,1,n) { cnt=0; For(j,1,n) if(j!=i) a[++cnt]=atan2(p[j].y-p[i].y,p[j].x-p[i].x); For(i,1,cnt) { if(a[i]<0) a[i]+=pi*2; a[cnt+i]=a[i]+pi*2; } sort(a+1,a+2*cnt+1); int r=1; c1=0; For(l,1,cnt) { while(r<2*cnt&&a[r+1]-a[l]<pi) r++; if(r-l) c1+=C(r-l,2); } c2+=tp-c1; } ans=(db)(c2+(C(n,4)-c2)*2)/(db)C(n,3)+3; printf("%.6lf\n",ans); return 0; }