Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- const double eps = 1e-6;
- struct pt {double x, y;};
- double len(pt a, pt b){
- double a1 = sqrt(a.x*a.x+a.y*a.y);
- double b1 = sqrt(b.x*b.x+b.y*b.y);
- return a1*b1;
- }
- double scalmltpl(pt a, pt b){
- return a.x*b.x + b.y*a.y;
- }
- double angle(pt a, pt b){
- return acos(scalmltpl(a,b)/len(a,b));
- }
- bool d_eq(double a, double b){
- //cout<<a<<";"<<b<<endl;
- return abs(a-b)<eps;
- }
- int main()
- {
- const double pi = 2*asin(1.0);
- int n;
- cin>>n;
- pt* points = new pt[n+1];
- const double ang = pi*(n-2)/n;
- int i;
- for (i = 0; i<n; i++)
- {
- cin >> points[i].x >> points[i].y;
- }
- points[n].x = points[0].x;
- points[n].y = points[0].y;
- pt line0, line1;
- line0.x = points[1].x - points[0].x;
- line0.y = points[1].y - points[0].y;
- for (i = 1; i < n; i++)
- {
- line1.x = points[i+1].x - points[i].x;
- line1.y = points[i+1].y - points[i].y;
- if(!d_eq(ang, angle(line1, line0)))
- {
- cout<<"NO";
- return 0;
- }
- line0.x = line1.x;
- line0.y = line1.y;
- }
- cout <<"YES";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment