2020牛客暑期多校训练营(第三场)C Operation Love

题目链接

思路:

首先判断两个距离为9的点,就是手掌底部的点,这个距离是唯一的,然后判断手掌的大拇指,就是离底部任意两个点其中一个距离为6的点,这个距离也是惟一的,最后判断这三个点之间的关系与朝向即可,注意,因为判断点会有开方,会有精度丢失,所以我们判断的时候不能是1e-6,而是1e-3.

代码:

#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int N=2e6+7;
const double eps=1e-8;
const int mod=1e9+7;
const int inf=0x7fffffff;
const double pi=3.1415926535;
using namespace std;
double solve(double a,double b,double x,double y)
{
    double sum=(a-x)*(a-x)+(b-y)*(b-y);
}
signed main()
{
    IOS;
    int t;
    cin>>t;
    while(t--)
    {
        double dix1,diy1,dix2,diy2,x1,y1,x2,y2,x3,y3;
        double x[21],y[21];
        for(int i=1;i<=20;i++)
        {
            cin>>x[i]>>y[i];
        }
        for(int i=1;i<=20;i++)
        {
            for(int j=1;j<=20;j++)
            {
                double num=solve(x[i],y[i],x[j],y[j]);
                if(fabs(num-81)<eps)
                {
                    dix1=x[i];
                    diy1=y[i];
                    dix2=x[j];
                    diy2=y[j];
                    break;
                }
            }
        }
        for(int i=1;i<=20;i++)
        {
            double num=solve(dix1,diy1,x[i],y[i]);
            if(fabs(num-36)<eps)
            {
                x1=x[i];
                y1=y[i];
                x2=dix1;
                y2=diy1;
                x3=dix2;
                y3=diy2;
                break;
            }
        }
        for(int i=1;i<=20;i++)
        {
            double num=solve(dix2,diy2,x[i],y[i]);
            if(fabs(num-36)<eps)
            {
                x1=x[i];
                y1=y[i];
                x2=dix2;
                y2=diy2;
                x3=dix1;
                y3=diy1;
                break;
            }
        }
        if(x1==x2)
        {
            if(y1>y2)
            {
                if(x3>x1)
                {
                    cout<<"right"<<endl;
                }
                else
                {
                    cout<<"left"<<endl;
                }
            }
            else
            {
                if(x3>x1)
                {
                    cout<<"left"<<endl;
                }
                else
                {
                    cout<<"right"<<endl;
                }
            }
        }
        else if(x1>x2)
        {
            if(y3>y2)
            {
                cout<<"left"<<endl;
            }
            else
            {
                cout<<"right"<<endl;
            }
        }
        else
        {
            if(y3>y2)
            {
                cout<<"right"<<endl;
            }
            else
            {
                cout<<"left"<<endl;
            }
        }
        cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<" "<<x3<<" "<<y3<<endl;
    }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值