杭电OJ 1174(C++)

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
	int T;
	cin >> T;
	double h1, r1, x1, y1, z1;
	double h2, r2, x2, y2, z2, x3, y3, z3;
	double a, b, c, x, y, z, m, n;
	while (T--)
	{
		cin >> h1 >> r1 >> x1 >> y1 >> z1;
		cin >> h2 >> r2 >> x2 >> y2 >> z2 >> x3 >> y3 >> z3;
		z1 = h1 + z1 - r1; //土匪头部中心Z坐标
		z2 = h2 * 0.9 + z2 - r2; //警察头部中心Z坐标
		a = x1 - x2;
		b = y1 - y2;
		c = z1 - z2;
		x = b * z3 - c * y3;
		y = c * x3 - a * z3;
		z = a * y3 - b * x3;
		m = sqrt(x * x + y * y + z * z);
		n = m / sqrt(x3 * x3 + y3 * y3 + z3 * z3);
		if (n <= r1 && (a * x3 + b * y3 + c * z3) > 0)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}
发布了138 篇原创文章 · 获赞 1 · 访问量 7026

猜你喜欢

转载自blog.csdn.net/Intelligence1028/article/details/104543891