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.
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.
Print "Yes" if the problem has a solution, "No" otherwise.
You can print each letter in any case (upper or lower).
0 1 1 1 1 0
Yes
1 1 0 0 1000 1000
No
In the first sample test, rotate the page around (0.5, 0.5) by .
In the second sample test, you can't find any solution.
题意:给定a,b,c三个点,求是否存在一个点d使a绕d旋转一定角度与b重合,b绕d旋转相同角度与c重合
因为a,b,c的位置使固定的且a,b,c不重合,要满足这个条件判断a,b,c不在一条直线上且Lab=Lbc(可以画图证明),因为数据较大,计算长度相等是相乘可能爆int
#pragma comment(linker,"/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<cmath>
#include<vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
#define pi acos(-1.0)
#define eps 1e-10
#define pf printf
#define sf scanf
#define lson rt<<1,l,m
#define rson rt<<1|1,m+1,r
#define ess tree[rt]
#define _s second
#define _f first
#define all(x) (x).begin,(x).end
#define mem(i,a) memset(i,a,sizeof i)
#define for0(i,a) for(int (i)=0;(i)<(a);(i)++)
#define for1(i,a) for(int (i)=1;(i)<=(a);(i)++)
#define mi ((l+r)>>1)
#define sqr(x) ((x)*(x))
const int inf=0x3f3f3f3f;
ll a,b,c,d,e,f;
ll length(ll a,ll b,ll c,ll d)
{
return sqr(a-c)+sqr(b-d);//不用返回double,计算平方和是否相等即可
}
bool check(ll a,ll b,ll c,ll d,ll e,ll f)
{
if((d-b)*(e-c)==(f-d)*(c-a))//计算斜率相等用乘法,防止除数为0
return 0;
return 1;
}
int main()
{
while(~sf("%I64d%I64d%I64d%I64d%I64d%I64d",&a,&b,&c,&d,&e,&f))
{
if(length(a,b,c,d)==length(c,d,e,f)&&check(a,b,c,d,e,f))
puts("Yes");
else
puts("No");
}
return 0;
}