Robot Race UVALive

来源:互联网 发布:tensorflow 英文教程 编辑:程序博客网 时间:2024/06/07 15:34

这个题就是让你去判断三点是否能够成锐角,然后确定相邻的两个点,枚举另外一个点,然后直接用点乘判断一下是否有锐角,如果有锐角输出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 longusing 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;    }}


原创粉丝点击