坑,直接把公路看成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;
}

HDU 1912的更多相关文章

  1. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  2. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  3. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  4. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  5. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  6. HDU 1796How many integers can you find(容斥原理)

    How many integers can you find Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d ...

  7. hdu 4481 Time travel(高斯求期望)(转)

    (转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pi ...

  8. HDU 3791二叉搜索树解题(解题报告)

    1.题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=3791 2.参考解题 http://blog.csdn.net/u013447865/articl ...

  9. hdu 4329

    problem:http://acm.hdu.edu.cn/showproblem.php?pid=4329 题意:模拟  a.     p(r)=   R'/i   rel(r)=(1||0)  R ...

随机推荐

  1. TCP打开文件传输(服务器端并发code)

    #include <stdio.h>#include <stdlib.h>#include <arpa/inet.h>#include <sys/types. ...

  2. Appium + python - swipe滑屏操作实例

    方法一: from appium import webdriverfrom time import sleep descred_caps = { "platformName":&q ...

  3. gdb打印vector

    1.gdb版本大于7.0 (gdb) p yourVector 2.打印整个vector (gdb) p *(yourVector._M_impl._M_start)@yourVector.size( ...

  4. struts2OGNL表达式(三)

    OGNL表达式 OGNL对象试图导航语言.${user.addr.name}这种写法就叫对象试图导航.Struts框架使用OGNL作为默认的表达式语言 OGNL不仅仅可以试图导航,支持比EL表达式更加 ...

  5. do…while语句

    有些情况下,不论条件是否满足,循环过程必须至少执行一次,这时可以采用do...while语句.就像如图7.4所示登录账号一样,需要先输入密码和账户名,后进行判断:如果密码始终不正确,则循环要求用户输入 ...

  6. Android 在线升级

    1.获取当前安装版本 //获取当前版本 public int getVersion(Context context){ ; try { version = context.getPackageMana ...

  7. amcharts简单demo(仪表盘)

    最近项目中展示数据有用到amcharts,一个小demo例子. <script src="<%=basePath%>amchart/amcharts.js" ty ...

  8. Mongo连接远程数据库

    mongo IP+Port CrabyterV5 首先这么操作是基于配置了环境变量的,可以参照http://www.cnblogs.com/daiyonghui/p/5209076.html mong ...

  9. .Net并行计算支持嵌套事务的方法

    问题背景 一年前,我们开始利用.Net 4.0的TPL(Task Parallel Library)并行计算技术对复杂计算的功能节点进行性能优化,这些复杂计算往往会包含大量对数据库的操作.在应用TPL ...

  10. (转)C#开发微信门户及应用(2)--微信消息的处理和应答

    http://www.cnblogs.com/wuhuacong/p/3614175.html 微信应用如火如荼,很多公司都希望搭上信息快车,这个是一个商机,也是一个技术的方向,因此,有空研究下.学习 ...