zoukankan      html  css  js  c++  java
  • HDU 1140 War on Weather

    http://acm.hdu.edu.cn/showproblem.php?pid=1140

    根据球的切点做简单的判断,一开始找到答案没有跳出循环,各种错。。。

    View Code
    #include <iostream>
    #include <cmath>
    using namespace std ;
    const double PI=acos(-1.0) ;//π的表示方法 
    struct point 
    {
        double x,y,z ;
    } ;
    double dis(point p1,point p2)
    {
        return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y)+(p1.z-p2.z)*(p1.z-p2.z)) ;
    }
    int main()
    {
        int k,m ;
        while(scanf("%d%d",&k,&m),(k||m))
        {
            point O ;
            O.x=O.y=O.z=0 ;
            point p[101] ;
            for(int i=0;i<k;i++)
                scanf("%lf%lf%lf",&p[i].x,&p[i].y,&p[i].z) ;
            double r=20000.0/PI ;
            int ans=0 ;
            while(m--)
            {
                point target ;
                scanf("%lf%lf%lf",&target.x,&target.y,&target.z) ;
                for(int i=0;i<k;i++)
                    if(dis(p[i],O)*dis(p[i],O)>=r*r+dis(p[i],target)*dis(p[i],target))
                    { 
                        ans++ ;
                        break ;
                    }
            }
            printf("%d\n",ans) ;
        }
        return 0 ;
    }
  • 相关阅读:
    linxu 网络管理
    Linux 命令2
    crontab命令
    Linux 命令
    Linux 命令
    Git命令
    GIT
    Python 修改文件内容
    logging模块
    CSS 选择器
  • 原文地址:https://www.cnblogs.com/xiaohongmao/p/2542793.html
Copyright © 2011-2022 走看看