Geometry 专栏收录该内容
12 篇文章 0 订阅

# 爆头

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

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

Input

Output

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

a - (b + c) = a - b + c

 4284349 2011-07-29 10:22:44 Accepted 1174 0MS 248K 702 B C++ 10SGetEternal{（。）（。）}!
#include <iostream>
#include <cstdlib>
using namespace std;
#define sq(x) ((x) * (x))

int main()
{
int T;
double h1, r1, x1, y1, z1, h2, r2, x2, y2, z2, x3, y3, z3;
double xp, yp, zp, d, t, dt;

scanf("%d", &T);
while (T--)
{
scanf("%lf%lf%lf%lf%lf", &h1, &r1, &x1, &y1, &z1);
scanf("%lf%lf%lf%lf%lf", &h2, &r2, &x2, &y2, &z2);
scanf("%lf%lf%lf", &x3, &y3, &z3);
z1 += h1 - r1;
z2 += 0.9 * h2 - r2;
d = sq(x3) + sq(y3) + sq(z3);
t = (x3 * (x1 - x2) + y3 * (y1 - y2) + z3 * (z1 - z2)) / d;
xp = x3 * t + x2;
yp = y3 * t + y2;
zp = z3 * t + z2;
dt = sq(r1) - sq(xp - x1) - sq(yp - y1) - sq(zp - z1);
puts(dt >= 0? "YES": "NO");
}

return 0;
}

• 0
点赞
• 0
评论
• 1
收藏
• 一键三连
• 扫一扫，分享海报

02-06 755

04-30 876
09-29 523
08-06 854
09-02 447
07-17 103
07-17 449
08-14 2455
03-18 147
04-27 58
06-09 1079
07-28 311
10-09 437
05-17 1528
©️2021 CSDN 皮肤主题: 大白 设计师:CSDN官方博客

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、C币套餐、付费专栏及课程。