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

题目描述:

Alice is a beauty in a robot society. So many robots want to marry her. Alice determines to marry a robot who can solve the following puzzle:

Firstly, the shape of Alice’s right palm is as follow:
在这里插入图片描述
And the shape of Alice’s left palm is symmetrical to her right palm.

In this puzzle, Alice will give the challenger many handprints of her palm. The challenger must correctly tell Alice each handprint is her left palm or right palm. Notice that the handprint of Alice’s palm is given by its 2D plane coordinates in clockwise or counterclockwise order. And The shape may be rotated and translated. But the shape won’t be zoomed in nor be zoomed out.

Although you are not a robot, you are interested in solving puzzles. Please try to solve this puzzle.

输入描述:

在这里插入图片描述

输出描述:

在这里插入图片描述

示例1

输入:
2
1.000000 0.000000
10.000000 0.000000
10.000000 8.000000
9.000000 8.000000
9.000000 5.000000
8.000000 5.000000
8.000000 10.000000
7.000000 10.000000
7.000000 5.000000
6.000000 5.000000
6.000000 10.000000
5.000000 10.000000
5.000000 5.000000
4.000000 5.000000
4.000000 10.000000
3.000000 10.000000
3.000000 3.000000
2.000000 3.000000
2.000000 6.000000
1.000000 6.000000
-1.000123 0.000000
-10.000123 0.000000
-10.000123 8.000000
-9.000123 8.000000
-9.000123 5.000000
-8.000123 5.000000
-8.000123 10.000000
-7.000123 10.000000
-7.000123 5.000000
-6.000123 5.000000
-6.000123 10.000000
-5.000123 10.000000
-5.000123 5.000000
-4.000123 5.000000
-4.000123 10.000000
-3.000123 10.000000
-3.000123 3.000000
-2.000123 3.000000
-2.000123 6.000000
-1.000123 6.000000
输出:
right
left

示例2

输入:
1
19.471068 -6.709056
13.814214 -1.052201
13.107107 -1.759308
15.228427 -3.880629
14.521320 -4.587735
10.985786 -1.052201
10.278680 -1.759308
13.814214 -5.294842
13.107107 -6.001949
9.571573 -2.466415
8.864466 -3.173522
12.400000 -6.709056
11.692893 -7.416162
8.157359 -3.880629
7.450253 -4.587735
12.400000 -9.537483
11.692893 -10.244590
9.571573 -8.123269
8.864466 -8.830376
13.107107 -13.073017
输出:
right

说明:

在这里插入图片描述

题目大意:逆时针或者顺时针给出二十个点,判断是左手还是右手

用向量的点乘和叉乘判断

#include<bits/stdc++.h>
using namespace std;
struct po
{
	double x,y;
} a[30];
double dis(po x,po y) //边长
{
	return sqrt((x.x-y.x)*(x.x-y.x)+(x.y-y.y)*(x.y-y.y));
}
double cj(po x,po y,po z) //叉积
{
	return (y.x-x.x)*(z.y-x.y)-(y.y-x.y)*(z.x-y.x);
}
int main()
{
	int t,i;
	bool flag;
	const double e=1e-5;
	scanf("%d",&t);
	while(t--)
	{
		flag=0;
		for(i=0;i<20;i++)
			scanf("%lf%lf",&a[i].x,&a[i].y);
		for(i=0;i<20;i++)
			if(fabs(dis(a[i],a[(i+1)%20])-9)<e)
			{
				po x=a[i],y=a[(i+1)%20],z=a[(i+2)%20];
				if(cj(x,y,z)>0 && fabs(dis(y,z)-6)<e || cj(x,y,z)<0 && fabs(dis(y,z)-8)<e) flag=1;
				break;
			}
				
		if(flag) printf("left\n");
		else printf("right\n");
	}
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值