Robot Race UVALive - 7020几何暴力

这个题就是让你去判断三点是否能够成锐角,然后确定相邻的两个点,枚举另外一个点,然后直接用点乘判断一下是否有锐角,如果有锐角输出unfair 否则输出fair

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <math.h>
#include <stack>
#include <utility>
#include <string>
#include <sstream>
#include <cstdlib>
#define LL long long
using namespace std;
const int INF = 0x3f3f3f3f;
const int maxn = 10000 + 10;
int dir[4][2] = {{1,0},{0,1},{-1,0},{0,-1}};
struct point
{
    LL x;LL y;
} p[maxn];
bool judge(point a,point b,point c)
{
    if((a.x - b.x)*(c.x - b.x) + (a.y - b.y)*(c.y - b.y) <= 0)
        return true;
    return false;
}
int main()
{
    int n;
    while(scanf("%d",&n) && n)
    {
        for(int i = 0; i < n; i++)
        {
            scanf("%lld%lld",&p[i].x,&p[i].y);
        }
        int flag = 0;
        for(int i = 0; i < n - 2; i++)
        {
            for(int j = i + 2; j < n; j++)
            {
                if(!judge(p[i],p[i+1],p[j]))
                {
                    flag = 1;
                    break;
                }
            }
            if(flag)
                break;
        }
        if(flag)
            cout<<"Unfair"<<endl;
        else
            cout<<"Fair"<<endl;
    }
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值