zoj3993

链接:zoj3993

题解

  • 首先要搞清楚这题的概率怎么算,以建筑物为圆心r为半径的圆在大圆以内的面积除以大圆面积。
  • 很显然在点到初始圆心以内的建筑物安全概率都是1,如果没有这样的点,就选距离圆心最近的点。
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    #include<cstring>
    #include<algorithm>
    #define rep(i,x,y) for(int i=x;i<=y;++i)
    #define repd(i,x,y) for(int i=x;i>=y;--i)
    #define ll long long
    #define lowbit(x) x&(-x)
    using namespace std;
    const int N=1e5+7;
    const double eps=1e-10;
    const int inf=0x3f3f3f3f;
    int T,R,r,n,ans[N];
    int main(){
    scanf("%d",&T);
    while(T--&&~scanf("%d%d%d",&n,&R,&r)){
    int res=max(2*r-R,R-2*r),mind=inf,tp,cnt=0;
    res*=res;
    rep(i,1,n){
    int x,y;scanf("%d%d",&x,&y);
    if(x*x+y*y<=res)tp=0;
    else tp=x*x+y*y;
    if(tp<mind){
    mind=tp;
    cnt=0;
    ans[++cnt]=i;
    }
    else if(tp==mind)ans[++cnt]=i;
    }
    printf("%d\n",cnt);
    rep(i,1,cnt)printf("%d%c",ans[i],i!=cnt?' ':'\n');
    }
    return 0;
    }