poj 1675 Happy Birthday!

与原点连线的最大夹角不小于120即可。

/*
 * Author: stormdpzh
 * Created Time: 2012/7/19 16:01:35
 * File Name: poj_1675.cpp
 */
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>

#define sz(v) ((int)(v).size())
#define rep(i, n) for(int i = 0; i < n; i++)
#define repf(i, a, b) for(int i = a; i <= b; i++)
#define repd(i, a, b) for(int i = a; i >= b; i--)
#define out(n) printf("%d\n", n)
#define mset(a, b) memset(a, b, sizeof(a))
#define wh(n) while(1 == scanf("%d", &n))
#define whz(n) while(1 == scanf("%d", &n) && n != 0)
#define lint long long

using namespace std;

const int MaxN = 1 << 30;
const double eps = 1e-8;
const double PI = 3.141592654;

int r;
int x[5], y[5];

int sgn(double d)
{
    if(d > eps) return 1;
    if(d < -eps) return -1;
    return 0;
}

double mymax(double a, double b)
{
    if(sgn(a - b) > 0) return a;
    return b;
}

double getAngle(int x1, int y1, int x2, int y2)
{
    double up = (double)(x1 * x2 + y1 * y2);
    double down = sqrt(double(x1 * x1 + y1 * y1)) * sqrt(double(x2 * x2 + y2 * y2));
    return acos(up / down) * 180.0 / PI;
}

double gao()
{
    double ang1 = getAngle(x[0], y[0], x[1], y[1]);
    double ang2 = getAngle(x[0], y[0], x[2], y[2]);
    double ang3 = getAngle(x[1], y[1], x[2], y[2]);
    return mymax(mymax(ang1, ang2), ang3);
}

int main()
{
    int t;
    wh(t) {
        while(t--) {
            scanf("%d", &r);
            rep(i, 3) scanf("%d%d", &x[i], &y[i]);
            bool flag = false;
            rep(i, 3) if(0 == x[i] && 0 == y[i]) {
                puts("No");
                flag = true;
                break;
            }
            if(flag) continue;
            double max_angle = gao();
            if(sgn(max_angle - 120.0) < 0) puts("No");
            else puts("Yes");            
        }
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值