高速公路(Highway,ACM/ICPC SEERC 2005,UVa1615)
2016-07-17 15:45
447 查看
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; }
相关文章推荐
- postman应用
- IOS Dev Intro - vImage scale
- leetcode 197. Rising Temperature
- 编译时的注解编写
- scala技术文章集锦
- 两个链表的第一个公共结点 java
- 283. Move Zeroes
- js基础汇总
- SPI flash debug trace
- python学习——进程vs线程
- BFPRT算法求无序数组中第k个值
- 微软下载
- 判断二分图——染色法
- DBUtil连接池
- uImage在内存中无法正常启动——UBoot-2010.06在TQ2440上的移植--机器码配对
- uImage在内存中无法正常启动——UBoot-2010.06在TQ2440上的移植--机器码配对
- uImage在内存中无法正常启动——UBoot-2010.06在TQ2440上的移植--机器码配对
- uImage在内存中无法正常启动——UBoot-2010.06在TQ2440上的移植--机器码配对
- uImage在内存中无法正常启动——UBoot-2010.06在TQ2440上的移植--机器码配对
- uImage在内存中无法正常启动——UBoot-2010.06在TQ2440上的移植--机器码配对