Codeforces851B

来源:互联网 发布:元数据和数据字典 编辑:程序博客网 时间:2024/04/20 05:30
B. 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).

题目大意:给定三个点a,b,c,问是否存在绕任意一点旋转任意角度后是否满足a点在原来b点的位置,b点在原来c点的位置。

分析:其实就是判断a,b,c是不是一个等腰三角形的问题,因为如果b在ac的垂直平分线上,那么经过一定旋转后必然可以满足

          题意,同时要注意a,b,c不能在同一直线上。

          我在这一题上的坑点主要是浮点数大小比较..又忘了怎么比较,还有计算过程中数据溢出,在数学题中一定要注意这些问题。

#include<bits/stdc++.h>using namespace std;const double eps=1e-6;int main(){    int ax,ay,bx,by,cx,cy;    cin>>ax>>ay>>bx>>by>>cx>>cy;    long double midx=(ax+cx)*1.0/2,midy=(ay+cy)*1.0/2;    long double len=fabs(ax-midx)*fabs(ax-midx)+fabs(ay-midy)*fabs(ay-midy);    long double len2=fabs(bx-midx)*fabs(bx-midx)+fabs(by-midy)*fabs(by-midy);    long double len3=fabs(ax-bx)*fabs(ax-bx)+fabs(ay-by)*fabs(ay-by);    //cout<<len<<"  "<<len2<<"  "<<len3<<endl;    if(len2==0)    {        cout<<"No"<<endl;        return 0;    }    if(fabs(len+len2-len3)<eps)        cout<<"Yes"<<endl;    else        cout<<"No"<<endl;    return 0;}