- #include
- #include
- #include
- using namespace std;
- const doubleeps = 1e-8;
- intcmp(double x)
- {
- if(fabs(x) < eps)return 0;
- if(x >0)return 1;
- return-1;
- }
- struct point
- {
- double x, y;
- point() {}
- point(doublea,double b):x(a),y(b) {}
- void input() {
- scanf("%lf%lf", &x, &y);
- }
- friend point operator- (constpoint &a,constpoint &b) {
- returnpoint(a.x-b.x, a.y-b.y);
- }
- double norm() {
- returnsqrt(x*x + y*y);
- }
- };
- struct cicle
- {
- point p;
- double r;
- void input() {
- scanf("%lf%lf%lf", &p.x, &p.y, &r);
- }
- };
- doubledot(constpoint &a,constpoint &b)
- {
- returna.x*b.x + a.y*b.y;
- }
- doubledet(constpoint &a,constpoint &b)
- {
- returna.x*b.y - a.y*b.x;
- }
- doubledist(constpoint &a,constpoint &b)
- {
- return(a-b).norm();
- }
- doubledis_point_segment(constpoint p,constpoint s,const point t)
- {
- if(cmp(dot(p-s,t-s))<0)return(p-s).norm();
- if(cmp(dot(p-t,s-t))<0)return(p-t).norm();
- returnfabs(det(s-p,t-p)/dist(s, t));
- }
- bool cross(cicle o, point a, point b, point c)
- {
- double d1, d2, d3;
- d1 = dist(o.p, a);
- d2 = dist(o.p, b);
- d3 = dist(o.p, c);
- if(d1o.r)
- return false;
- if(dis_point_segment(o.p, a, b)>o.r
- && dis_point_segment(o.p, a, c)>o.r
- && dis_point_segment(o.p, b, c)>o.r)
- return false;
- return true;
- }
- int main()
- {
- //freopen("1.txt", "r", stdin);
- int T;
- scanf("%d", &T);
- while(T--) {
- cicle o;
- o.input();
- point a, b, c;
- a.input();
- b.input();
- c.input();
- if (cross(o, a, b, c))
- printf("Yes\n");
- else
- printf("No\n");
- }
- return 0;
- }
来源: http://www.bubuko.com/infodetail-2135246.html