codeforces851B

Arpa and an exam about geometry

问题描述

给你一张纸上的3个点,A,B,C
问你能不能用手按住纸上的一个位置并且旋转,使得新的A取代了B的位置,新的B取代了C的位置。

Input

第一行6个整数,表示三个点的坐标Ax,Ay,Bx,By,Cx,Cy. 每个数字的绝对值<=10^9

Output

如果可以就输出"Yes",否则输出"No".

Example

Input

0 1 1 1 1 0

Output

Yes

Input

1 1 0 0 1000 1000

Output

No

Note

第一个样例,你可以绕着点(0.5),(0.5)旋转90°

这个题目其实只要判断AB和BC的长度是否相等,相等则输出Yes,反之输出No。除此之外,唯一的一个坑就是AB,BC长度相等,但A,B,C共线。所以需要判断三点共线。

代码如下:

#include<stdio.h>
#include<assert.h>
#include<string.h>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const int maxn = 100;
ll Ax, Ay, Bx, By, Cx, Cy;
ll ans1;
ll ans2;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> Ax >> Ay >> Bx >> By >> Cx >> Cy;
	if ((Ax*By - Ay*Bx) + (Bx*Cy - Cx*By) + (Cx*Ay - Cy*Ax) == 0) {
		cout << "No" << endl;
		return 0;
	}
	ans1 = (Ax - Bx)*(Ax - Bx) + (Ay - By)*(Ay - By);
	ans2 = (Bx - Cx)*(Bx - Cx) + (By - Cy)*(By - Cy);
	if (ans1 == ans2)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

猜你喜欢

转载自blog.csdn.net/zsnowwolfy/article/details/82793414