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;
}
View Code

 

转载于:https://www.cnblogs.com/Achenchen/p/8643017.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值