HDU 1912
2024-08-31 07:32:46
坑,直接把公路看成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;
}
最新文章
- unity 利用ugui 制作技能冷却效果
- CAS示例环境部署及配置
- C# 扩展类
- 动手学习TCP: 环境搭建
- Easy Problem-map和vector的使用
- shell常用代码积累
- Filter过滤器
- Entity Framework笔记(二)
- 设计模式(6)--Adapter(适配器模式)--结构型
- 解析 C# 7中的元组类型(ValueTuple)
- SpringMVC 中配置 Swagger 插件.
- 洛谷P3802:小魔女帕琪
- AJAX的简单示例:注册校验
- solr 7.6 安装部署与遇到的问题
- 【转载】利用一个堆溢出漏洞实现 VMware 虚拟机逃逸
- CDI(Weld)高级<;4>; Event(事件) (转)
- .NET:C#的匿名委托 和 Java的匿名局部内部类
- 实用SQL语句
- meven 配置
- 关于 vee-validate直接引用的方法