zoukankan      html  css  js  c++  java
  • UVALive

    题意:有个机器人,他在一条线路上走着,他的显示器上应该显示的是路径的剩余距离,但实际上显示屏显示的是欧氏距离,所以问你在路径上有没有一个点,满足距离突然变大(比前一刻距离大)

    题解:求一下任意2条直线的家教关系,当然你也可以计算点是否在相邻两侧的点为直径的园内,本质是一样的

    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    const int maxn=1e4+5;
    struct point
    {
        ll x, y;
    }p[maxn];
    
    bool judge(point a, point b, point c)
    {
        return (b.x-a.x)*(c.x-b.x)+(b.y-a.y)*(c.y-b.y)>=0;
    }
    
    int main()
    {
        int n;
        while(~scanf("%d",&n)&&n){
            memset(p,0,sizeof(p));
            for(int i=0;i<n;i++){
                scanf("%lld%lld",&p[i].x,&p[i].y);
            }
            bool ok = true;
            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])){
                        ok = false;
                        break;
                    }
                }
                if(!ok) break;
            }
            printf("%s
    ",ok?"Fair":"Unfair");
        }
        return 0;
    }
    /*
    5
    5 5
    15 5
    25 15
    15 25
    5 25
    4
    0 0
    1 0
    2 1
    3 0
    0
    */
  • 相关阅读:
    socket通信原理
    socket通信基础内容
    内核中断过程
    爬虫基础模块
    关于多个运算符的问题
    前戏
    js扩展
    加密
    django之form
    Django
  • 原文地址:https://www.cnblogs.com/lalalatianlalu/p/7672741.html
Copyright © 2011-2022 走看看