题目:Radar Installation

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

排序之后贪心一下就ok

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

  1. #include<cstdio>
  2. #include<cstring>
  3. #include<iostream>
  4. #include<algorithm>
  5. #include<queue>
  6. #include<cmath>
  7. using namespace std;
  8. ;
  9. int n,c[maxn];
  10. struct ac{
  11. double x,y;
  12. }a[maxn];
  13. bool cmp(ac q,ac w){
  14. return q.x<w.x;
  15. }
  16. int main(){
  17. ;
  18. double d;
  19. bool fa;
  20. cin>>n>>d;
  21. ||d!=){
  22. fa=;
  23. ;j<=n;j++){
  24. double x,y;
  25. scanf("%lf%lf",&x,&y);
  26. ;
  27. else{
  28. a[j].x=x*1.0-sqrt(d * d - y * y);
  29. a[j].y=x*1.0+sqrt(d * d - y * y);
  30. }
  31. }
  32. ;
  33. ) printf("Case %d: -1\n",tot++);
  34. else{
  35. sort(a+,a++n,cmp);
  36. ac aa=a[];
  37. ;j<=n;j++){
  38. if(a[j].x>aa.y){
  39. ans++;
  40. aa=a[j];
  41. }else if(a[j].y<aa.y){
  42. aa=a[j];
  43. }
  44. }
  45. printf("Case %d: %d\n",tot++,ans);
  46. }
  47. cin>>n>>d;
  48. }
  49. ;
  50. }

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. C# DataTable详解

    添加引用 using System.Data; 创建表 //创建一个空表 DataTable dt = new DataTable(); //创建一个名为"Table_New"的空 ...

  2. C++类的内存结构

    摘自Jerry19880126 简单类 class Base { int a; int b; public: void CommonFunction(); }; 简单类继承 class Derived ...

  3. C#读书笔记:线程,任务和同步

    前言 学习C#两个多月了,像当初实习做PHP开发一样,也是由着一个个Feature需求,慢慢掌握了很多相关的编程技巧.本次主要记录下学习C# 多线程的相关知识. 参考书籍:<Csharp高级编程 ...

  4. checkbox操作判断 Jquery选择器

    function checkAll(d){ console.log(d); console.log(d.checked); //注意 这里是d不是$(d) 不是jQuery对象 if(d.checke ...

  5. vue cli3 vue.config.js 配置详情

    module.exports = {   // 基本路径   baseUrl: process.env.NODE_ENV === 'production'     ? '/'     : '/',   ...

  6. re正则表达式-1

    匹配/查找/替换/分割函数: import re re.match('aa','aabbcc') 返回对象中span为开始位置和结束位置 re.match('aa','bbaacc') #返回值为No ...

  7. Django--权限信息操作

    一 . 权限控制 表结构的设计 rbca(Role Based Access Control)  基于角色的权限控制 3个model  5张表 class User(models.Model): # ...

  8. wget 下载网页

    如有转载,不胜荣幸.http://www.cnblogs.com/aaron-agu/ wget --http-user=username --http-passwd=password http:/w ...

  9. Python——列表操作

    一.列表中所有元素出现的次数,并输出为字典模式 def count_list(list): b_list = {} for i in set(list): b_list[i] = list.count ...

  10. atlassian、jira账户无法注册来这里

    进入https://www.atlassian.com/try 注册成功 登陆 再次到邮箱点击链接 登陆成功(已经处于登陆状态:此时你已经拥有一个atlassian账户了)