标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2002 Accepted Submission(s): 868
/* * @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[10]; 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[1] = Line(x3, y3, z3); line[3] = Line(x1, y1, h1 - r1 / 2.0 + z1); line[4] = Line(x2, y2, h2 * 0.9 - r2 / 2.0 + z2); line[2] = Line(line[3].x - line[4].x, line[3].y - line[4].y, line[3].z - line[4].z); double tmp = chaji(line[1], line[2]); tmp /= sqrt(x3 * x3 + y3 * y3 + z3 * z3); if (tmp - r1 <= eps) printf("YES\n"); else printf("NO\n"); } return 0; }
标签:
原文地址:http://www.cnblogs.com/LinKArftc/p/4925923.html