题目:Radar Installation

对于x轴上方的每个建筑 可以计算出x轴上一段区间可以包含这个点 所以就转化成 有多少个区间可以涵盖这所有的点

排序之后贪心一下就ok

用cin 好像一直t看了好多blog 改了scanf 过了

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
using namespace std;
;
int n,c[maxn];
struct ac{
    double x,y;
}a[maxn];
bool cmp(ac q,ac w){
  return q.x<w.x;
}
int main(){
    ;
    double d;
    bool fa;
    cin>>n>>d;
    ||d!=){
       fa=;
       ;j<=n;j++){
         double x,y;
         scanf("%lf%lf",&x,&y);
         ;
         else{
           a[j].x=x*1.0-sqrt(d * d - y * y);
           a[j].y=x*1.0+sqrt(d * d - y * y);
         }
       }
       ;
       ) printf("Case %d: -1\n",tot++);
       else{
          sort(a+,a++n,cmp);
          ac aa=a[];
          ;j<=n;j++){
             if(a[j].x>aa.y){
                ans++;
                aa=a[j];
             }else if(a[j].y<aa.y){
                aa=a[j];
             }
          }
          printf("Case %d: %d\n",tot++,ans);
       }
       cin>>n>>d;
    }
    ;
}

POJ--1328 Radar Installation(贪心 排序)的更多相关文章

  1. POJ 1328 Radar Installation 贪心 A

    POJ 1328 Radar Installation https://vjudge.net/problem/POJ-1328 题目: Assume the coasting is an infini ...

  2. poj 1328 Radar Installation(贪心+快排)

    Description Assume the coasting is an infinite straight line. Land is in one side of coasting, sea i ...

  3. POJ 1328 Radar Installation 贪心算法

    Description Assume the coasting is an infinite straight line. Land is in one side of coasting, sea i ...

  4. POJ - 1328 Radar Installation(贪心区间选点+小学平面几何)

    Input The input consists of several test cases. The first line of each case contains two integers n ...

  5. poj 1328 Radar Installation(贪心)

    题目:http://poj.org/problem?id=1328   题意:建立一个平面坐标,x轴上方是海洋,x轴下方是陆地.在海上有n个小岛,每个小岛看做一个点.然后在x轴上有雷达,雷达能覆盖的范 ...

  6. POJ 1328 Radar Installation 贪心 难度:1

    http://poj.org/problem?id=1328 思路: 1.肯定y大于d的情况下答案为-1,其他时候必定有非负整数解 2.x,y同时考虑是较为麻烦的,想办法消掉y,用d^2-y^2获得圆 ...

  7. POJ 1328 Radar Installation 贪心题解

    本题是贪心法题解.只是须要自己观察出规律.这就不easy了,非常easy出错. 一般网上做法是找区间的方法. 这里给出一个独特的方法: 1 依照x轴大小排序 2 从最左边的点循环.首先找到最小x轴的圆 ...

  8. POJ 1328 Radar Installation#贪心(坐标几何题)

    (- ̄▽ ̄)-* #include<iostream> #include<cstdio> #include<algorithm> #include<cmath ...

  9. 贪心 POJ 1328 Radar Installation

    题目地址:http://poj.org/problem?id=1328 /* 贪心 (转载)题意:有一条海岸线,在海岸线上方是大海,海中有一些岛屿, 这些岛的位置已知,海岸线上有雷达,雷达的覆盖半径知 ...

  10. poj 1328 Radar Installation 排序贪心

    Radar Installation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 56702   Accepted: 12 ...

随机推荐

  1. IdentityServer4【Introduction】之概括

    The Big Picture 大多数现代应用看起来都像下面的样子: 大多数的交互是下面这样: 浏览器与web应用之间的通信 web应用和web APIs之间的通信(这两者有时是独立的,有时是有用户参 ...

  2. Java 基本数据类型 及 == 与 equals 方法的区别

    Java数据类型分为基本数据类型与引用数据类型. 1 基本数据类型 byte:Java中最小的数据类型,在内存中占1个字节(8 bit),取值范围-128~127,默认值0 short:短整型,2个字 ...

  3. C# Note20: 制作延时改变显示的标题栏

    前言 在使用wpf构建一个窗体时,其中有这样一个功能,在保存数据或加载数据时,我们希望在改变标题栏的显示以标志当前保存成功的状态或者加载数据的名称信息,而且标题信息更新显示几秒后,再恢复到默认的状态. ...

  4. 字符串正则替换replace第二个参数是函数

    zepto中 //将字符串转成驼峰式的格式 camelize = function (str) { return str.replace(/-+(.)?/g, function (match, chr ...

  5. springboot项目小总结

    使用模板引擎 thyemlef 可以直接将 html文件进行导入 loginhtml文件   html中常用的表达式 <link href="asserts/css/signin.cs ...

  6. 【git】如何去解决fatal: refusing to merge unrelated histories

    我在Github新建一个仓库,写了License,然后把本地一个写了很久仓库上传. 先pull,因为两个仓库不同,发现refusing to merge unrelated histories,无法p ...

  7. h5简易手写板

    ............. 我该说点什么呢,开头居然不知道想说点什么!好吧不知道说什么,我们就来说说这个手写板吧,虽然这个手写板现在没什么用,但是.....,好像的确没什么用啊! 只是存粹哪里练手的的 ...

  8. Prism框架中加载类库中时其中第三方类dll提示无法加载程序集

    Prism框架是采用一种依赖注入的方式动态加载程序集,能够在程序需要加载的时候将程序集注入到里面去,实现程序的热插拔效果,而且采用这种框架能够让我们进行一个大项目的独立开发,在最近的一个项目中在独立开 ...

  9. Spring标签之Bean @Scope

    @Bean 的用法 @Bean是一个方法级别上的注解,主要用在@Configuration注解的类里,也可以用在@Component注解的类里.添加的bean的id为方法名 定义bean 下面是@Co ...

  10. SSM+shiro及相关插件的整合maven所有依赖,详细注释版,自用,持续更新

    整合了SSM+shiro框架,slf4j+logback日志,及一些好用的插件PageHelper,mybatis-generator,Lombok,fastjson等等 <?xml versi ...