Codeforces Round #432 (Div. 2)B题 (等弦对等弧)

时间:2022-09-12 14:51:21

题目大意是让a,b,c三点,旋转后a落到b上,b落到c上,c无所谓。问存不存在这样一个旋转点。

其实任意一个三角形都有外接圆,所以经过一定的旋转,a一定可以到b,b也一定可以到c,但是如果要

同时发生的话就得旋转相同的角度使之发生,所以边ab == bc(等弦对等弧)。

需注意,在同一直线上的三点一定不可以。

判断是否在同一直线看斜率,然后算边长即可。

写这道题就想mark一下:1、判断斜率是否相等最好用乘法,可避免分母为0的特殊判断。

2、比较两边是否相等,用坐标算出边的平方即可,不用开根号,避免精度问题。

例如sqrt(1e18+1) 和sqrt(1e18),就会判相等。

附代码:

#include<bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
const int maxn = 2e5+5;
const double eps = 1e-11;
const int ff = 0x3f3f3f3f;

int main()
{
	ll xa,xb,xc,ya,yb,yc;
	cin>>xa>>ya>>xb>>yb>>xc>>yc;
	double k1,k2;
	if((yb-ya)*(xc-xa) == (yc-ya)*(xb-xa))
	{
		cout<<"No"<<endl;
		return 0;
	}
	if((xb-xa)*(xb-xa)+(yb-ya)*(yb-ya) == (xb-xc)*(xb-xc)+(yb-yc)*(yb-yc))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	
	return 0;
}


Arpa and an exam about geometry
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Arpa is taking a geometry exam. Here is the last problem of the exam.

You are given three points a, b, c.

Find a point and an angle such that if we rotate the page around the point by the angle, the new position of a is the same as the old position of b, and the new position of b is the same as the old position of c.

Arpa is doubting if the problem has a solution or not (i.e. if there exists a point and an angle satisfying the condition). Help Arpa determine if the question has a solution or not.

Input

The only line contains six integers ax, ay, bx, by, cx, cy (|ax|, |ay|, |bx|, |by|, |cx|, |cy| ≤ 109). It's guaranteed that the points are distinct.

Output

Print "Yes" if the problem has a solution, "No" otherwise.

You can print each letter in any case (upper or lower).

Examples
input
0 1 1 1 1 0
output
Yes
input
1 1 0 0 1000 1000
output
No
Note

In the first sample test, rotate the page around (0.5, 0.5) by Codeforces Round #432 (Div. 2)B题 (等弦对等弧).

In the second sample test, you can't find any solution.