Codeforces Round #432 (Div. 2) B. Arpa and an exam about geometry(数学水题)

来源:互联网 发布:东华软件金融部 编辑:程序博客网 时间:2024/05/31 00:40

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).

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 .

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


题解:

比赛还在进行但是我已经写不动了,10分钟过a题(太水不想写题解),20分钟过b题。。c题看不懂,d题不会做,e题。。。算了吧,虽然这题很水但还是水一发博客

题意:

给你3个点的坐标,问你是否能找到一个点,以该点为中心旋转一定的角度使得a与b重合,b与c重合

思路:

直接判断只要两个线段长度相同而且三个点不在同一直线上就行了

ps:

这题之前用double型40组数据出错估计是因为double精度不够,还有就是斜率不存在的时候会出问题,把数据类型改成long long,把斜率判等写成乘法就好了

暂时ac的代码:

#include<iostream>#include<cstring>#include<stdio.h>#include<math.h>#include<string>#include<stdio.h>#include<queue>#include<stack>#include<map>#include<vector>#include<deque>#include<algorithm>using namespace std;#define INF 100861111#define ll long long#define eps 1e-7#define maxn 20int main(){    long long x1,y1,x2,y2,x3,y3,k1,k2,d1,d2;    scanf("%lld%lld%lld%lld%lld%lld",&x1,&y1,&x2,&y2,&x3,&y3);    d1=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);    d2=(x2-x3)*(x2-x3)+(y2-y3)*(y2-y3);    if(d1!=d2)    {        printf("No\n");        return 0;    }    if((x2-x3)*(y1-y2)==(x1-x2)*(y2-y3))    {        printf("No\n");    }    else        printf("Yes\n");    return 0;}





阅读全文
0 0
原创粉丝点击