English appre:

an infinite straight line:一条无限长的直线

on the coasting:在海岸线上

Cartesian coordinate system,

题目地址:http://poj.org/problem?id=1328

我的代码:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std; struct dao
{
double x,y;
}da[10000];
bool cmp(dao a,dao b)
{
return (a.y<b.y)||(a.y==b.y && a.x>b.x);
} int main()
{
int n,d;
double x1,y1;
int k=0;
while(~scanf("%d%d",&n,&d)&&(n||d))
{
int ans=1;
for(int i=0;i<n;i++)
{
scanf("%lf%lf",&x1,&y1);
da[i].x=x1-sqrt((double)d*(double)d-(double)y1*y1);
da[i].y=x1+sqrt((double)d*(double)d-(double)y1*y1);
if((d-y1)<0||d<=0) ans=-1;
} if(ans==-1)
{
printf("Case %d: -1\n",++k);
continue;
}
else
{
sort(da,da+n,cmp);
double t1=da[0].y;
for(int i=1;i<n;i++)
if(da[i].x>t1)//要是用=号,有些数据不可通过。
{
ans++;
t1=da[i].y;//更新右范围
}
printf("Case %d: %d\n",++k, ans);
}
}
}

  

Radar Installation(利用数据有序化进行贪心选择)的更多相关文章

  1. (贪心5.2.6)URAL 1014 Product of Digits(利用数据有序化进行贪心选择)

    /* * URAL_1014.cpp * * Created on: 2013年10月11日 * Author: Administrator */ #include <iostream> ...

  2. Radar Installation(POJ 1328 区间贪心)

    Radar Installation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 68578   Accepted: 15 ...

  3. POJ 1328 Radar Installation(很新颖的贪心,区间贪心)

    Radar Installation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 106491   Accepted: 2 ...

  4. (贪心5.2.1)UVA 10026 Shoemaker's Problem(利用数据有序化来进行贪心选择)

    /* * UVA_10026.cpp * * Created on: 2013年10月10日 * Author: Administrator */ #include <iostream> ...

  5. 【贪心】「poj1328」Radar Installation

    建模:二维转一维:贪心 Description Assume the coasting is an infinite straight line. Land is in one side of coa ...

  6. 贪心 POJ 1328 Radar Installation

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

  7. poj 1328 Radar Installation(nyoj 287 Radar):贪心

    点击打开链接 Radar Installation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 43490   Accep ...

  8. poj 1328 Radar Installation(贪心)

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

  9. poj 1328 Radar Installation (简单的贪心)

    Radar Installation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 42925   Accepted: 94 ...

随机推荐

  1. 洛谷P4526 【模板】自适应辛普森法2

    P4526 [模板]自适应辛普森法2 洛谷传送门 题目描述 计算积分 保留至小数点后5位.若积分发散,请输出"orz". 输入格式 一行,包含一个实数,为a的值 输出格式 一行,积 ...

  2. filter逻辑bug

    复合筛选,有个要求是如果筛选条件是空就不传,加了一个逻辑 看着没什么问题,但是存在bug,当重置单一筛选条件时,赋空不能奏效,比如我重置symbol为空,之前是qqq,因为有非空的判断所有并不能奏效导 ...

  3. VISIO 的一些技巧

    1.复制绘图 如果格式改变,在“设计”选项卡里将“将主题运用于新建的形状”前面的√去掉

  4. linq行转列

    using System;using System.Collections.Generic;using System.Data;using System.Linq;using System.Text; ...

  5. PHP OOP

    <?php //1. Class and object /* object-oriented concept an object can be almost any items or conce ...

  6. Json与Ajax(注册实例)

    需要在服务器上进行哈 jquery的ajax方法: // jquery请求 $.ajax({ url: "./server/slider.json", type: "po ...

  7. VAR向量自回归模型学习笔记2

    向量自回归模型 今天的你 和昨天的你 和前天的你,是否具有相关性. 1. 定义 向量自回归(VAR,Vector Auto regression)分析联合内生变量间的动态关系 联合:n个变量间的相互影 ...

  8. QS Network ZOJ - 1586 板子题

    #include<iostream> #include<algorithm> using namespace std; ; struct edge{ int a,b; doub ...

  9. MySQL优化(三)——主从复制

    1.MySQL高可用        主从复制      一主多备      多主多备           2.MySQL主从复制        主机所有写的数据都会生成二进制SQL日志执行文件,从机只 ...

  10. Normalizing flows

    probability VS likelihood: https://zhuanlan.zhihu.com/p/25768606 http://sdsy888.me/%E9%9A%8F%E7%AC%9 ...