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. DC-8靶机渗透实战

    前言: 本文将讲述通过信息收集,再web站点的sql注入漏洞加john爆破登录后台,然后找到远程代码执行漏洞getshell,最后用exim4命令提权漏洞进行权限提升拿到最终的flag. 0x00 环 ...

  2. node-express处理表单的接口

    写一个小接口,用postman测试接口是否可行

  3. JS:获取标签的6个方法+获取html+获取body

    JS 获取标签的方法 通过class: document.getElementsByClassName('class名');返回数组通过name: document.getElementsByName ...

  4. pillow 模块

    pillow模块 图片处理 中文文档 安装 pip install Pillow 对图片旋转90度显示 from PIL import Image im=Image.open("t.jpg& ...

  5. CodeForces - 1107E 区间DP

    和紫书上的Blocks UVA - 10559几乎是同一道题,只不过是得分计算不同 不过看了半天紫书上的题才会的,当时理解不够深刻啊 不过这是一道很好区间DP题 细节看代码 #include<c ...

  6. ASP.NET Identity登录原理

    https://www.cnblogs.com/jesse2013/p/aspnet-identity-claims-based-authentication-and-owin.html 如何实现登录 ...

  7. 优先队列-UVA10603

    #include<cstdio> #include<cstring> #include<queue> using namespace std; typedef st ...

  8. PAT (Basic Level) Practice (中文)1046 划拳 (15 分)

    划拳是古老中国酒文化的一个有趣的组成部分.酒桌上两人划拳的方法为:每人口中喊出一个数字,同时用手比划出一个数字.如果谁比划出的数字正好等于两人喊出的数字之和,谁就赢了,输家罚一杯酒.两人同赢或两人同输 ...

  9. 五、JVM之堆内存

    堆结构分代图 堆结构分代的意义 Java虚拟机根据对象存活的周期不同,把堆内存划分为几块,一般分为新生代.老年代和永久代(对HotSpot虚拟机而言),这就是JVM的内存分代策略. 堆内存是虚拟机管理 ...

  10. Educational Codeforces Round 81 (Rated for Div. 2) C. Obtain The String

    题目链接:http://codeforces.com/contest/1295/problem/C 题目:给定字符串s,t.  给定一个空串z,需要按照规则把z构造成 string z == stri ...