poj 1675 Happy Birthday!

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

/*
 * Author: stormdpzh
 * Created Time: 2012/7/19 16:01:35
 * File Name: poj_1675.cpp
 */
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

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


你可能感兴趣的:(poj,up,file)