There are three berries on a round birthday cake. You are required to divide the cake into three identical parts such that each part contains exactly one berry. To make it easy, it is assumed that the radius of the berries is 0 and each part of the cake is a sector with 120 degrees. Any line that divides the cake should not go through any berry.
Input
The first line contains a single integer t (1 <= t <= 20) that indicates the number of test cases. Then follow the t cases. Each case contains exactly 7 integers r, x1, y1, x2, y2, x3 and y3. r is the radius of the cake, (xi, yi) is the coordinates of i-th berry. The center of the cake is at (0, 0) and it's confirmed that all the berries will be on the cake.
Output
For each case, output 'Yes' if there is a valid solution, 'No' otherwise.
Sample Input
2 2 1 1 -1 1 0 -1 10 0 9 1 8 -1 8
Sample Output
Yes No
给你三个豆 在原点为圆心半径为r的圆内 可以可以切成三等分 让每个豆在不同的块里面
每等分120度 看他们之间是不是有超过120度的 有就YES
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
const double pi=3.1415926;
int main()
{
int t;
cin>>t;
while(t--)
{
double r;
double x1,y1,x2,y2,x3,y3;
cin>>r>>x1>>y1>>x2>>y2>>x3>>y3;
double angl1;
double angl2;
double angl3;
if((x1==0&&y1==0)||(x2==0&&y2==0)||(x3==0&&y3==0))
{
cout<<"No"<<endl;
}
else
{
angl1=acos(((x1*x1+y1*y1)+(x2*x2+y2*y2)-((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)))/(2*sqrt(x1*x1+y1*y1)*sqrt(x2*x2+y2*y2)));
angl2=acos(((x1*x1+y1*y1)+(x3*x3+y3*y3)-((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3)))/(2*sqrt(x1*x1+y1*y1)*sqrt(x3*x3+y3*y3)));
angl3=acos(((x2*x2+y2*y2)+(x3*x3+y3*y3)-((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3)))/(2*sqrt(x2*x2+y2*y2)*sqrt(x3*x3+y3*y3)));
angl1=angl1*180/pi;
angl2=angl2*180/pi;
angl3=angl3*180/pi;
double maxn;
maxn=max(angl1,angl2);
maxn=max(maxn,angl3);
if(maxn<120)
{
cout<<"No"<<endl;
}
else
{
cout<<"Yes"<<endl;
}
}
}
return 0;
}