题目: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. mybatis二级缓存详解

    1  二级缓存简介 二级缓存是在多个SqlSession在同一个Mapper文件中共享的缓存,它是Mapper级别的,其作用域是Mapper文件中的namespace,默认是不开启的.看如下图: 1. ...

  2. java连接CentOS7上的redis

    这篇博客写得挺全的: https://blog.csdn.net/achenyuan/article/details/78521831?locationNum=3&fps=1 我也是跟着这篇博 ...

  3. day 7 -1 进程理论知识

    一.进程的定义 进程(Process)是计算机中的程序关于某数据集合上的一次运行活动,是系统进行资源分配和调度的基本单位,是操作系统结构的基础.在早期面向进程设计的计算机结构中,进程是程序的基本执行实 ...

  4. freemarker 简单操作

    操作字符串函数 1. substring(start,end)从一个字符串中截取子串 start:截取子串开始的索引,start必须大于等于0,小于等于end end: 截取子串的长度,end必须大于 ...

  5. 压测工具使用(vegeta)

    一.压测工具vegeta 1.介绍 Vegeta 是一个用 Go 语言编写的多功能的 HTTP 负载测试工具,它提供了命令行工具和一个开发库. 官方地址:https://github.com/tsen ...

  6. maven 中的pom中的 dependencyManagement 和 dependencies

    参考:maven pom.xml 中 dependencyManagement和dependencies详解 现在的项目基本上都是使用多module来管理的,这就涉及到一个问题,多module之间如何 ...

  7. APP test

    在讲APP测试之前,先讲一下,目前APP的操作系统以及APP相关基础知识. 一.APP基础知识 1.操作系统# 现在移动端的操作系统主流的分为两种:(1)安卓系统 (2)IOS系统. 2.安卓系统# ...

  8. 提示“Web打印服务CLodop未安装启动”的各种原因和解决方法

    旧版提示:"CLodop云打印服务(localhost本地)未安装启动!"新版提示:"Web打印服务CLodop未安装启动,点击这里下载执行安装(若此前已安装过,可点这里 ...

  9. rmse均方根误差

    rmse=sqrt(sum((w-r).^2)/length(w))

  10. Span<T>

    Introduction Span<T> is a new type we are adding to the platform to represent contiguous regio ...