高速公路(Highway,ACM/ICPC SEERC 2005,UVa1615)

I think:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
struct port
{
long long x,y,l,r;
};
int cmp(const void *a,const void *b)
{
struct port *x=(struct port *)a;
struct port *y=(struct port *)b;
return x->l - y->l; }
struct port p[1000000];
int main(void)
{
long long wayLen,d,i,v,sum;
long long c,tem;
while(scanf("%lld%lld%lld",&wayLen,&d,&v)!=EOF)
{
sum=1;
for(i=0; i<v; i++)
{
scanf("%lld%lld",&p[i].x,&p[i].y);
c=sqrt(d*d-p[i].y*p[i].y);
p[i].r=c+p[i].x;
p[i].l=p[i].x-c;
}
qsort(p,v,sizeof(p[0]),cmp);
tem=p[0].r;
for(i=1; i<v; i++)
{
if(p[i].l<=tem)
continue;
else
{
tem=p[i].r;
++sum;
}
}
printf("%lld\n",sum);
}
return 0;
}
高速公路(Highway,ACM/ICPC SEERC 2005,UVa1615)的更多相关文章
- [C++]最小生成元 (Digit Generator, ACM/ICPC Seoul 2005, UVa1583)
Question 例题3-5 最小生成元 (Digit Generator, ACM/ICPC Seoul 2005, UVa1583) 如果x+x的各个数字之和得到y,就是说x是y的生成元.给出n( ...
- 分子量 (Molar Mass,ACM/ICPC Seoul 2005,UVa1586)
习题 3-3 分子量 (Molar Mass,ACM/ICPC Seoul 2005,UVa1586) 给出一种物质的分子式(不带括号),求分子量.本题中的分子式只包含4种原子,分别为C,H,O,N, ...
- 生成元(Digit Generator, ACM/ICPC Seoul 2005, UVa1583)
如果x加上x的各个数字之和得到y,就说x是y的生成元.给出n(1≤n≤100000),求最小 生成元.无解输出0.例如,n=216,121,2005时的解分别为198,0,1979. [分析] 本题看 ...
- 得分(Score,ACM/ICPC Seoul 2005,UVa 1585)
#include<stdio.h> int main(void) { char b; int t,cou,sum; scanf("%d",&t); getcha ...
- 生成元(Digit Generator ,ACM/ICPC Seoul 2005 ,UVa 1583)
生成元:如果 x 加上 x 各个数字之和得到y,则说x是y的生成元. n(1<=n<=100000),求最小生成元,无解输出0. 例如:n=216 , 解是:198 198+1+9+8=2 ...
- 得分(Score, ACM/ICPC Seoul 2005,UVa 1585)
#include<cstdio>#include<cstdlib>#include<cstring>int main(){ char s[80];//输入OOXXO ...
- 生成元(Digit Generator,ACM/ICPC Seoul 2005,UVa 1583)
#include<cstdio>#include<cstdlib>#include<cstring>using namespace std;int t, n, a, ...
- UVa 1585 - Score - ACM/ICPC Seoul 2005 解题报告 - C语言
1.题目大意 给出一个由O和X组成的字符串(长度为80以内),每个O的得分为目前连续出现的O的数量,X得分为0,统计得分. 2.思路 实在说不出了,这题没过脑AC的.直接贴代码吧.=_= 3.代码 # ...
- hduoj 4706 Herding 2013 ACM/ICPC Asia Regional Online —— Warmup
hduoj 4706 Children's Day 2013 ACM/ICPC Asia Regional Online —— Warmup Herding Time Limit: 2000/1000 ...
随机推荐
- C# 延迟处理类 Lazy
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Lazy ...
- js屏蔽回车键
document.onkeydown = function () { if (window.event && window.event.keyCode == 13 ...
- JS 之继承
ECMAScript继承是通过原型链来继承的.基本思想是利用原型来让一个引用类型继承另一个引用类型的属性和方法,使原型变为另一个对象的实例.通过原型链实现继承时,不能使用对象字面量创建原型方法,避免重 ...
- Caffe学习系列(18): 绘制网络模型
python/draw_net.py, 这个文件,就是用来绘制网络模型的.也就是将网络模型由prototxt变成一张图片. 在绘制之前,需要先安装两个库 1.安装GraphViz # sudo apt ...
- [CareerCup] 13.2 Compare Hash Table and STL Map 比较哈希表和Map
13.2 Compare and contrast a hash table and an STL map. How is a hash table implemented? If the numbe ...
- android官方开源的高性能异步加载网络图片的Gridview例子
这个是我在安卓安卓巴士上看到的资料,放到这儿共享下.这个例子android官方提供的,其中讲解了如何异步加载网络图片,以及在gridview中高效率的显示图片此代码很好的解决了加载大量图片时,报OOM ...
- [USACO2003][poj2187]Beauty Contest(凸包+旋转卡壳)
http://poj.org/problem?id=2187 题意:老题了,求平面内最远点对(让本渣默默想到了悲剧的AHOI2012……) 分析: nlogn的凸包+旋转卡壳 附:http://www ...
- android之对话、单复框的使用
对话框 通过builder来构建一个单选框 package xidian.dy.com.chujia; import android.content.DialogInterface; import a ...
- DOM(五)事件对象
浏览器中的事件都是以对象的形式存在的,同样ie浏览器与标准dom浏览器之间存在获取事件对象上也存在差别.在ie浏览器中事件对象是windows对象的一个属性event,访问通常采用如下方法. oP.o ...
- mysql配置详解
mysql有以下几种日志: 错误日志: log-err 查询日志: log 慢查询日志: log-slow-queries 更新日志: log-update 二进制日志: ...