Problem Description
The sky was brushed, and the stars were cold in a black sky. What a wonderful night. You observed this, sometimes the stars can form a regular polygon in the sky if we connect them properly. You want to the record these moments by your smart camera. Of course, you cannot stay awake all night for capturing. So-decide to-write a program running on the smart camera to check whether the stars can form a regular polygon and cap Ture these moments automatically.
Formally, a regular polygon is a convex polygon whose angles was all equal and all its sides has the same length. The area of a regular polygon must is nonzero. We say the stars can form a regular polygon if they is exactly the vertices of some regular polygon. To simplify the problem, we project the sky to a two-dimensional plane here, and you just need to check whether the stars Can form a regular polygon in this plane.
InputThe first line contains a integerT indicating the total number of test cases. Each test case begins with an integern, denoting the number of stars in the sky. FollowingNlines, each contains2 integersXI,YI, describe the coordinates ofN Stars.
1≤T≤300
3≤n ≤100
< Span id= "mathjax-span-40" class= "Mrow" >− 10000≤xi,y i≤ 10000
all coordinates is distinct.
OutputFor each test case, please output "' YES '" If the Stars can form a regular polygon. Otherwise, Output "' NO '" (both without quotes).
Sample Input330 01 11 040 00 11 01 150 00 10 22 22 0
Sample OutputNoyesno
Test Instructions: ask if you are regular polygon.
idea: the blind violence xd. Direct storage of all points between the lines of the edge length, even the length of the same polygon must have N/2 and N, odd polygons the same edge length must be n.
/** @Date: 2016-12-10-22.55 * @Author: Lweleth ([email protected]) * @Link: https://github.com/* @Versi On: *///#include <stdio.h>//#include <iostream>//#include <string.h>//#include <algorithm>/ /#include <utility>//#include <vector>//#include <map>//#include <set>//#include <string >//#include <stack>//#include <queue> #include <bits/stdc++.h> #define LL long long#define PII pair <int,int> #define MP (x, y) Make_pair ((x), (y)) #define FI first#define se second#define PB (x) push_back ((x)) #define M MG (x) memset ((x), -1,sizeof (x)) #define MMF (x) memset ((x), 0,sizeof (x)) #define MMI (x) memset ((x), INF, sizeof (x)) using namespace Std;const int INF = 0x3f3f3f3f;const int N = 1e5+20;const double eps = 1e-8;struct yuu{double x; double y; BOOL operator = = (CONST Yuu &a) const {return (a.x = = this->x) && (a.y = this->y); }}S[110], T[n];int CMP (Yuu A, Yuu b) {if (a.x! =b.x) return a.x > b.x; return a.y > B.y;} Map<double, Int>q;int Main () {int T; scanf ("%d", &t); while (t--) {int n; scanf ("%d", &n); Q.clear (); for (int i = 1; I <= n; i++) scanf ("%lf%lf", &s[i].x, &S[I].Y); int cnt = 0; for (int i = 1, i <= N; i++) {for (int j = i + 1; j <= N; j + +) {Double m x = Fabs (s[i].x-s[j].x); Double my = Fabs (S[I].Y-S[J].Y); Double len = mx * mx + my * my; q[len]++; }} int flag = 0; for (Auto i = Q.begin (); I! = Q.end (); i++) {if (N & 1 && I->second! = N) { flag = 1; Break } else if (n 2 = = 0) {if (I->second! = N/2 && I->second! = N) {flag = 1; Break }}} if (flag) printf ("no\n"); else printf ("yes\n"); } return 0;}
HDU 5533Dancing Stars on Me basic geometry