爆头

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2002    Accepted Submission(s): 868

Problem Description
gameboy是一个CS高手,他最喜欢的就是扮演警察,手持M4爆土匪的头。也许这里有人没玩过CS,有必要介绍一下“爆头”这个术语:所谓爆头,就是子弹直接命中对方的头部,以秒杀敌人。

现在用一个三维的直角坐标系来描述游戏中的三维空间(水平面为xoy平面,z轴正方向是上方)。假设游戏中角色的头是一个标准的球。告诉你土匪的身高,头部半径,所站位置的坐标;gameboy所控警察的身高,头部半径,所站位置的坐标,以及枪头所指方向的单位向量。gameboy所控警察所握的是M4,抢瞄准时枪膛中的子弹跟视线基本同线,我们忽略它们的距离,就当成同线。由于土匪手持AK47,所以他是很嚣张地正立着。而警察手持M4,正在瞄准,由于瞄准时身体微弯,视线从头心出发,他头部的实际高度比正立时低10%。

你的任务就是,计算gameboy在这一刻扣下扳机,能否爆土匪的头。注意:这里忽略子弹的直径和重力作用,也就是说子弹是无限小的,弹道是一条笔直的射线,警察与土匪间没有障碍物。并且只要子弹擦到头部,哪怕是边缘,也算爆头。

 
Input
测试数据的第一行有一个正整数T,表示有T组测试数据。每组数据的第一行有五个实数,h1,r1,x1,y1,z1,分别表示土匪的身高,头部半径以及所站的位置。第二行有八个实数,h2,r2,x2,y2,z2,x3,y3,z3,分别表示警察的身高,头部半径,所站位置,以及枪头所指方向的方向向量。
 
Output
每一组输入数据对应一行输出。如果能爆土匪的头,输出"YES",否则输出"NO"。
 
Sample Input
2
1.62 0.1 10.0 10.0 10.0
1.80 0.09 0.0 0.0 0.0 1.0 1.0 1.0
1.62 0.1 0.0 0.0 0.0
1.80 0.09 10.0 10.0 10.0 -1.0 -1.0 -1.0
 
Sample Output
YES
YES
 
Author
lwg
 
/*
* @Author: LinK
* @Date: 2015-10-31 17:53:33
* @Last Modified by: LinK
* @Last Modified time: 2015-10-31 18:12:22
*/ #include <map>
#include <set>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <cstdio>
#include <string>
#include <utility>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define eps 1e-8
#define randin srand((unsigned int)time(NULL))
#define input freopen("input.txt","r",stdin)
#define debug(s) cout << "s = " << s << endl;
#define outstars cout << "*************" << endl;
const double PI = acos(-1.0);
const int inf = 0x3f3f3f3f;
const int INF = 0x7fffffff;
typedef long long ll; struct Line {
double x, y, z;
Line() {}
Line(double _x, double _y, double _z) : x(_x), y(_y), z(_z) {}
} line[]; double chaji(Line a,Line b) {
double x1 = a.x;
double y1 = a.y;
double z1 = a.z;
double x2 = b.x;
double y2 = b.y;
double z2 = b.z;
double x = y1 * z2 - z1 * y2;
double y = z1 * x2 - x1 * z2;
double z = x1 * y2 - y1 * x2;
return sqrt(x * x + y * y + z * z);
} int main() {
double h1, r1, x1, y1, z1;
double h2, r2, x2, y2, z2, x3, y3, z3;
int T;
scanf("%d", &T);
while (T --) {
scanf("%lf %lf %lf %lf %lf", &h1, &r1, &x1, &y1, &z1);
scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &h2, &r2, &x2, &y2, &z2, &x3, &y3, &z3);
line[] = Line(x3, y3, z3);
line[] = Line(x1, y1, h1 - r1 / 2.0 + z1);
line[] = Line(x2, y2, h2 * 0.9 - r2 / 2.0 + z2);
line[] = Line(line[].x - line[].x, line[].y - line[].y, line[].z - line[].z);
double tmp = chaji(line[], line[]);
tmp /= sqrt(x3 * x3 + y3 * y3 + z3 * z3);
if (tmp - r1 <= eps) printf("YES\n");
else printf("NO\n");
} return ;
}

最新文章

  1. 了不起的全能MAC系统监测工具iStat Menus 5下载
  2. 彻底搞定 C/C++ 指针
  3. Get a developer license for windows store app
  4. 271. Encode and Decode Strings
  5. HDU 4618 Palindrome Sub-Array (2013多校2 1008 暴力)
  6. 小米2及其他Android手机无法连接mac解决方案
  7. 关闭MyEclipse的Quick Update
  8. C++不同进制整数
  9. Codevs 1684 垃圾陷阱
  10. dell笔记本通过uefi+gpt模式安装win10系统
  11. T-SQL和PL/SQL 区别
  12. xdebug的安装和配置方法
  13. wpf中静态资源和动态资源的区别
  14. ASM ClassReader failed to parse class file解决方法
  15. java基础学习总结——流
  16. 2010-10-08在浏览器中兼容+jQuery3
  17. 利用ThreadLocal管理事务
  18. 回收机制GC
  19. &lt;A&gt;标签电子邮件链接
  20. Linux定时器工具

热门文章

  1. 为Zabbix配置Nova服务、Keystone和Placement进程CPU和内存usage监控
  2. 洛谷P1189&#39;SEARCH&#39;
  3. HDU 1698 Just a Hook(线段树区间覆盖)
  4. 第十一次ScrumMeeting会议
  5. JAVA_四大代码块_普通代码块、构造代码块、静态代码块、同步代码块。
  6. PHP与webserver【简书看到的】
  7. java生成和解析二维码
  8. [剑指Offer] 13.调整数组顺序使奇数位于偶数前面
  9. CF763E Timofey and our friends animals
  10. 【Cf edu 30 B. Balanced Substring】