HAOI2014 遥感监测
题目链接:戳我
比较水的一个题,直接处理点,找在直线上的可以覆盖到它的区间,然后做最小线段覆盖即可;
代码如下:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define eps 1e-10
using namespace std;
int r,n,ans;
struct Node{int x,y;double l,r;}node[110];
inline bool cmp(struct Node x,struct Node y){return x.r<y.r;}
int main()
{
#ifndef ONLINE_JUDGE
freopen("ce.in","r",stdin);
#endif
scanf("%d%d",&n,&r);
for(int i=1;i<=n;i++)
{
scanf("%d%d",&node[i].x,&node[i].y);
node[i].l=1.0*node[i].x-sqrt(r*r*1.0-node[i].y*node[i].y);
node[i].r=1.0*node[i].x+sqrt(r*r*1.0-node[i].y*node[i].y);
}
sort(&node[1],&node[1+n],cmp);
double rr=node[1].r;
for(int i=2;i<=n;i++)
{
if(node[i].l-eps>rr) ans++,rr=node[i].r;
}
printf("%d\n",ans+1);
return 0;
}