HDU 5533 Dancing Stars on Me calculates the geometry of the blind violence

Source: Internet
Author: User
Tags cas

Dancing Stars on Me

Time limit:2000/1000 MS (java/others) Memory limit:262144/262144 K (java/others)
Total submission (s): 1184 Accepted Submission (s): 651


Problem DescriptionThe Sky is brushed clean by the wind 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 integerTindicating the total number of test cases. Each test case begins with an integerN, denoting the number of stars in the sky. FollowingNLines, each contains2Integersxi,yi , describe the coordinates ofNStars.

1≤T≤
3≤n≤
−10000≤xi,yi≤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

SOURCE2015ACM/ICPC Asia Changchun Station-Replay (thanks to northeast Normal University)

Recommendhujie | We have carefully selected several similar problems for you:5877 5876 5875 5874 5873 give some points to ask the composition of the graph is not just a blind violence on it (in fact, encountered this problem Basically, it's only violent. And all points are separated from each other, and then the order of the smallest point and the nth small point is equal to
#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> #include < queue> #include <vector> #include <iomanip> #include <math.h> #include <map>using namespace STD; #define FIN freopen ("Input.txt", "R", stdin), #define FOUT freopen ("Output.txt", "w", stdout); #define INF 0x3f3f 3f3f#define infll 0x3f3f3f3f3f3f3f#define Lson l,m,rt<<1#define rson m+1,r,rt<<1|1typedef Long Long LL typedef pair<int,int> PII;CONST int MAXN = 1e2 + 5;int T, N;int A[MAXN], B[MAXN];d ouble DIS[MAXN * maxn];int Main ()    {//fin scanf ("%d", &t);        while (t--) {scanf ("%d", &n);        for (int i = 1; I <= n; i++) {scanf ("%d%d", &a[i], &b[i]);        } int cas = 0; for (int i = 1, i <= n-1; i++) {for (int j = i + 1; j <= N; j + +) {Dis[++cas] = (double)            sqrt ((A[j]-a[i]) * (A[j]-a[i]) + (B[j]-b[i]) * (B[j]-b[i]));      }  } sort (dis + 1, dis + cas + 1);//for (int i = 1; I <= cas; i++) {//cout << Dis[i] &lt        ;< endl;//}//cout << "cas=" << cas << Endl;        if (dis[1] = = Dis[n]) printf ("yes\n");    else printf ("no\n"); } return 0;}

  

HDU 5533 Dancing Stars on Me calculates the geometry of the blind violence

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.