坑,直接把公路看成X轴来做,然后,排序扫描一下,你懂的。

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std; const int MAXN=10100; struct Village{
double l,r;
};
Village p[MAXN]; bool cmp(Village A, Village B){
if(A.l<B.l)return true;
else if(A.l==B.l){
if(A.r<B.r)return true;
}
return false;
} int main(){
int n,L,D; double x,y;
while(scanf("%d%d%d",&L,&D,&n)!=EOF){
for(int i=0;i<n;i++){
scanf("%lf%lf",&x,&y);
double d=sqrt(D*D-y*y);
p[i].l=x-d; p[i].r=x+d;
}
int counted=1;
sort(p,p+n,cmp);
double s=p[0].r;
for(int i=1;i<n;i++){
if(p[i].l<=s)
continue;
else{
s=p[i].r;
counted++;
}
}
printf("%d\n",counted);
}
return 0;
}

最新文章

  1. unity 利用ugui 制作技能冷却效果
  2. CAS示例环境部署及配置
  3. C# 扩展类
  4. 动手学习TCP: 环境搭建
  5. Easy Problem-map和vector的使用
  6. shell常用代码积累
  7. Filter过滤器
  8. Entity Framework笔记(二)
  9. 设计模式(6)--Adapter(适配器模式)--结构型
  10. 解析 C# 7中的元组类型(ValueTuple)
  11. SpringMVC 中配置 Swagger 插件.
  12. 洛谷P3802:小魔女帕琪
  13. AJAX的简单示例:注册校验
  14. solr 7.6 安装部署与遇到的问题
  15. 【转载】利用一个堆溢出漏洞实现 VMware 虚拟机逃逸
  16. CDI(Weld)高级&lt;4&gt; Event(事件) (转)
  17. .NET:C#的匿名委托 和 Java的匿名局部内部类
  18. 实用SQL语句
  19. meven 配置
  20. 关于 vee-validate直接引用的方法

热门文章

  1. Coursera Algorithms week1 查并集 练习测验:2 Union-find with specific canonical element
  2. php write excel
  3. 浅谈自学Python之路(day3)
  4. Python 33(2)进程理论
  5. 2019手机号码JS正则表达式
  6. E - A Trivial Problem(求满足x!的尾数恰好有m个0的所有x)
  7. C#方法的练习
  8. (转)vuex2.0 基本使用(2) --- mutation 和 action
  9. 基于CXF搭建webService
  10. MYSQL 45道练习题