zoukankan      html  css  js  c++  java
  • 高速公路(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
    ",sum);
        }
        return 0;
    }
    

      

  • 相关阅读:
    IOC
    软件问题
    POJO和JavaBean
    tail命令
    实现质数遍历并输出所需时间
    完数
    break、continue
    *各种形状
    for、while、do-while
    jenkins实现maven项目自动化部署tomcat
  • 原文地址:https://www.cnblogs.com/A--Q/p/5678678.html
Copyright © 2011-2022 走看看