poj 1675 Happy Birthday!

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;
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值