简单题。
首先判断两个圆是否都与坐标轴相交,有一个不相交直接输出NO
剩下的情况都是相交的。让算一算四个交点。最后只有四种情况了。
#include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; int main() { double Vx, x, y, T1, R1, T2, R2; while (~scanf("%lf%lf%lf", &Vx, &x, &y)) { scanf("%lf%lf%lf%lf", &T1, &R1, &T2, &R2); double TT1, TT2, RR1, RR2; if (R1 > R2)RR1 = R1, RR2 = R2, TT1 = T1, TT2 = T2; else RR1 = R2, RR2 = R1, TT1 = T2, TT2 = T1; if (fabs(y)>R1 || fabs(y)>R2) { printf("No\n"); continue; } double A, B, C, D; A = x - sqrt(RR1*RR1 - y*y); B = x + sqrt(RR1*RR1 - y*y); C = x - sqrt(RR2*RR2 - y*y); D = x + sqrt(RR2*RR2 - y*y); if (A>0 && A / Vx >= TT1 && (C - A) / Vx >= TT2) printf("Yes\n"); else if (A>0 && A / Vx >= TT1 && (D - A) / Vx >= TT2) printf("Yes\n"); else if (C>0 && C / Vx >= TT2 && (B - C) / Vx >= TT1) printf("Yes\n"); else if (D>0 && D / Vx >= TT2 && (B - D) / Vx >= TT1) printf("Yes\n"); else printf("No\n"); } return 0; }
时间: 2024-10-26 07:30:37