题目: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. CMake--List用法

    list(LENGTH <list><output variable>) list(GET <list> <elementindex> [<ele ...

  2. jenkins配置SSH远程服务器连接

    之前用jenkins做了一个自动发布测试,配置任务的Post Steps时,选择的是执行shell命令.如下图: 这是在本192.168.26.233服务器上测试的,此服务器上运行jenkins,to ...

  3. 校园电商项目2(基于SSM)——模块设计

    步骤一:各模块职责 步骤二:实体类设计 package com.figsprite.o2o.bean; import java.util.Date; public class Area { priva ...

  4. Android——MaterialDesign之二DrawerLayout

    滑动菜单--DrawerLayout 滑动菜单就是把一些菜单选项隐藏起来,而不是放置主屏幕中,然后可以通过滑动的方式将菜单显示出来,具有非常的画面效果,就是类似侧边滑动. 例子:需要上一次的Toolb ...

  5. URL & QRcode auto generator

    URL & QRcode auto generator 二维码 npm & qrcode https://www.npmjs.com/package/qrcode https://ww ...

  6. replace只能输入小数

    case "checkPrice": tr.find(".layui-table-edit").keyup(function () { var $input = ...

  7. gevent监测单线程下的io进行切换

    from gevent import monkey;monkey.patch_all() import gevent import time def eat(name): print('%s eat ...

  8. 打包一个UWP APP

    Before packaging your app Test your app. Before you package your app for store submission, make sure ...

  9. 51nod-1445-变色DNA(最短路)

    题意:题目是说从0到n-1,我还是习惯从1到n,所以以下我都这么写,大概题意就是(i, j)==‘Y’表示可以从i颜色变成j颜色,然后问我们最少删除几个会影响结果的‘Y’,能到n这个颜色: 没有意义的 ...

  10. Nginx TSL/SSL优化握手性能

    L:131