D. Aerodynamic
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Guy-Manuel and Thomas are going to build a polygon spaceship.

You're given a strictly convex (i. e. no three points are collinear) polygon (x,y)→. The picture below depicts an example of the translation:

Codeforces 1300D

Define P(x,y) which contain the origin are drawn in colored:

Codeforces 1300D

The spaceship has the best aerodynamic performance if similar.

Input

The first line of input will contain a single integer 3≤n≤105) — the number of points.

The i-th vertex.

It is guaranteed that these points are listed in counterclockwise order and these points form a strictly convex polygon.

Output

Output "YES" in a separate line, if 

Examples
input
Copy
4
1 0
4 1
3 4
0 3
output
Copy
YES
input
Copy
3
100 86
50 0
150 0
output
Copy
nO
input
Copy
8
0 0
1 0
2 1
3 3
4 6
3 6
2 5
1 3
output
Copy
YES
Note

The following image shows the first sample: both T are squares. The second sample was shown in the statements.

Codeforces 1300D

 

 

/*
    这个题真的很简单,但是当时比赛的时候抱着只做三个题的心态去的,所以题做的很慢,最后时间不够了,后悔莫及,这题就是只要给出的图形对边平行且相等就输出YES,其它情况一律输出NO
*/
#include<iostream>
#include<cstdio>
#include<cmath>
#define maxn 100010
#define eps 0.0000001
using namespace std;
int n;
double a[maxn],b[maxn],dis[maxn]; 
double calc(double a1,double b1,double a2,double b2){
    double res=(a1-a2)*(a1-a2)+(b1-b2)*(b1-b2);
    return res;
}
int main(){
    scanf("%d",&n);
    if(n%2==1){
        puts("nO");
        return 0;
    }
    for(int i=1;i<=n;i++){
        scanf("%lf%lf",&a[i],&b[i]);
        if(i!=1){
            dis[i]=calc(a[i],b[i],a[i-1],b[i-1]);
        }
    }
    dis[1]=calc(a[1],b[1],a[n],b[n]);
    int w1=a[n],w2=b[n];
    for(int i=n;i>=2;i--){
        a[i]-=a[i-1];
        b[i]-=b[i-1];
    }
    a[1]-=w1;b[1]-=w2;
    for(int i=2;i<=n;i++){
        int tmp=i+n/2;
        tmp%=n;
        if(tmp==0)tmp=n;
        if(dis[i]-dis[tmp]!=0||a[i]*b[tmp]!=a[tmp]*b[i]){
            puts("nO");
            return 0;
        }
    }
    puts("YES");
    return 0;
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-11
  • 2021-08-24
  • 2022-12-23
猜你喜欢
  • 2021-10-14
  • 2021-06-08
  • 2022-12-23
  • 2021-11-21
  • 2021-06-09
  • 2021-06-15
  • 2021-08-18
相关资源
相似解决方案