Codeforces 851B

来源:互联网 发布:最短路径算法floyd实例 编辑:程序博客网 时间:2024/06/03 13:09

链接:

  http://codeforces.com/contest/851/problem/B


题目:

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.


题意:

  给你三个点abc的坐标,问你能否绕某个点旋转一定的角度让a转至b的位置,并且与此同时b也转至c的位置。


思路:

  首先,三个点一定能构成一个圆弧,于是转化一下问题就可以变成判断三个点两两在圆弧上的距离是否相等。因为在圆弧上的时候到圆心的距离都相等,所以当且仅当|ab|等于|bc|且三点不共线的时候,输出Yes,否则输出No


实现:

#include <bits/stdc++.h>using namespace std;long long x[3], y[3];long long calc(int a, int b) {    long long xx = x[a] - x[b], yy = y[a] - y[b];    return xx*xx + yy*yy;}long long check() {    return (x[2] - x[1])*(y[1] - y[0]) == (x[1] - x[0])*(y[2] - y[1]);}int main() {#ifndef ONLINE_JUDGE    freopen("in.txt","r",stdin);#endif    for(int i=0 ; i<3 ; i++) scanf("%lld%lld", x+i, y+i);    if(calc(0,1) == calc(1,2) && !check()) return puts("Yes"), 0;    return puts("No"), 0;}
原创粉丝点击