题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1174

解题报告:就是用到了三维向量的点积来求点到直线的距离,向量(x1,y1,z1)与(x2,y2,z2)的点积是:x1*x2+y1*y2+z1*z2.

然后要注意的就是当两个向量的夹角大于等于90度时,无论如何都不能射中.

 #include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
const double PI = acos(-1.0);
struct Point
{
double x,y,z;
Point(double a = ,double b = ,double c = ) :x(a),y(b),z(c) {}
friend Point operator + (Point a,Point b)
{
return Point(a.x+b.x,a.y+b.y,a.z+b.z);
}
friend Point operator - (Point a,Point b)
{
return Point(a.x-b.x,a.y-b.y,a.z-b.z);
}
};
double length(Point a)
{
return sqrt(a.x*a.x+a.y*a.y+a.z*a.z);
}
int main()
{
// freopen("in","r",stdin);
int T;
double h1,r1,h2,r2;
Point p1,p2,p;
scanf("%d",&T);
while(T--)
{
scanf("%lf%lf%lf%lf%lf",&h1,&r1,&p1.x,&p1.y,&p1.z);
scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&h2,&r2,&p2.x,&p2.y,&p2.z,&p.x,&p.y,&p.z);
Point o1 = p2,o2 = p1;
o2.z += (h1 - r1);
o1.z += (0.9 * h2 - r2);
Point oo = o2 - o1;
double temp = (oo.x*p.x + oo.y * p.y + oo.z * p.z) / length(oo) / length(p);
double angle = acos(temp); //求夹角
if(angle <= )
{
puts("NO");
continue;
}
double D = sin(angle) * length(oo);
printf(D <= r1? "YES\n":"NO\n");
}
return ;
}

HDU 1174 爆头(计算几何)的更多相关文章

  1. hdu 1174:爆头(计算几何,三维叉积求点到线的距离)

    爆头 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submissi ...

  2. HDU 1174 题解(计算几何)

    题面: 爆头 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submis ...

  3. HDU 4998 Rotate (计算几何)

    HDU 4998 Rotate (计算几何) 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=4998 Description Noting is more ...

  4. hdu 4643 GSM 计算几何 - 点线关系

    /* hdu 4643 GSM 计算几何 - 点线关系 N个城市,任意两个城市之间都有沿他们之间直线的铁路 M个基站 问从城市A到城市B需要切换几次基站 当从基站a切换到基站b时,切换的地点就是ab的 ...

  5. HDU - 1174:爆头 (三维平面点到射线的距离)

    pro:给定警察的射击位置,设计方向,敌人的位置,敌人的头部半径,问子弹是否可以射到头部. sol:即问头部中点到子弹射线的距离是否小于等于头部半径. 和二维的点到直线一样的操作. det/dot: ...

  6. hdu 1086(计算几何入门题——计算线段交点个数)

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=1086 You can Solve a Geometry Problem too Time Limit: 2 ...

  7. hdu 4613 Points<计算几何>

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=4613 题意: 判断一个集合中的点能不能由另一个集合中的点,通过平移,旋转,放缩得到~ 思路:先求出集合中的 ...

  8. HDU 5295 Unstable 计算几何

    Unstable 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5295 Description Rasen had lost in labyrint ...

  9. 2017多校第6场 HDU 6097 Mindis 计算几何,圆的反演

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6097 题意:有一个圆心在原点的圆,给定圆的半径,给定P.Q两点坐标(PO=QO,P.Q不在圆外),取圆 ...

随机推荐

  1. Android之Proguard语法

    -include {filename} 从给定的文件中读取配置参数 -basedirectory {directoryname} 指定基础目录为以后相对的档案名称 -injars {class_pat ...

  2. Git删除tag

    git tag -d v2016062101 删除本地tag git push origin --delete tag v2016062101 删除远程tag

  3. bs4_2

     QQ:231469242 欢迎交流 Parsing HTML with the BeautifulSoup Module Beautiful Soup是用于提取HTML网页信息的模板,Beautif ...

  4. delphi---控件使用

    1.TBitBtn控件 属性:Glyph,指定要显示的位图:    Layout ,设置位图在按钮的位置:Kind,要想用自设位图,这个属性要设置bkCustom; 2.TTreeView TTree ...

  5. Visual Studio无法查找或打开 PDB 文件解决办法

    Visual Studio无法查找或打开 PDB 文件解决办法 用VS调试程序时,有时会在VS底部的“输出”框中提示“无法查找或打开 PDB 文件”.这该怎么解决呢? 下面,我们以VS2013为例,来 ...

  6. Css常用收集

    /*-------------------------------------- 圆角*/ -webkit-border-radius: 4px;  -moz-border-radius: 4px; ...

  7. SQL JOINS

  8. Spring系列之beanFactory与ApplicationContext

    一.BeanFactoryBeanFactory 是 Spring 的“心脏”.它就是 Spring IoC 容器的真面目.Spring 使用 BeanFactory 来实例化.配置和管理 Bean. ...

  9. 在github上创建新分支

    在github上创建仓库: Create a new repository on the command line touch README.md git init git add README.md ...

  10. 关于Mysql错误:./bin/mysqld_safe --user=mysql& [1] 32710 121003 16:40:22 mysqld_safe Logging to '/var/log/mysqld.log'. 121003 16:40:22 mysqld_s

    [root@www]# ./bin/mysqld_safe --user=mysql&[1] 32710[root@www]# 121003 16:40:22 mysqld_safe Logg ...