2015ACM/ICPC亚洲区长春站 G hdu 5533 Dancing Stars on Me
Dancing Stars on Me
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 186 Accepted Submission(s): 124
Formally, a regular polygon is a convex polygon whose angles are all equal and all its sides have the same length. The area of a regular polygon must be nonzero. We say the stars can form a regular polygon if they are 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.
1≤T≤300
3≤n≤100
−10000≤xi,yi≤10000
All coordinates are distinct.
3
0 0
1 1
1 0
4
0 0
0 1
1 0
1 1
5
0 0
0 1
0 2
2 2
2 0
YES
NO
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
using namespace std;
typedef long long LL;
typedef double DB;
#define MIT (2147483647)
#define MLL (1000000000000000001LL)
#define INF (1000000001)
#define For(i, s, t) for(int i = (s); i <= (t); i ++)
#define Ford(i, s, t) for(int i = (s); i >= (t); i --)
#define Rep(i, n) for(int i = (0); i < (n); i ++)
#define Repn(i, n) for(int i = (n)-1; i >= (0); i --)
#define mk make_pair
#define ft first
#define sd second
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define sz(x) ((int) (x).size())
inline void SetIO(string Name)
{
string Input = Name + ".in";
string Output = Name + ".out";
freopen(Input.c_str(), "r", stdin);
freopen(Output.c_str(), "w", stdout);
} inline int Getint()
{
char ch = ' ';
int Ret = ;
bool Flag = ;
while(!(ch >= '' && ch <= ''))
{
if(ch == '-') Flag ^= ;
ch = getchar();
}
while(ch >= '' && ch <= '')
{
Ret = Ret * + ch - '';
ch = getchar();
}
return Flag ? -Ret : Ret;
} const int N = ;
struct Point
{
int x, y;
} Arr[N];
int n; inline void Solve(); inline void Input()
{
int TestNumber = Getint();
while(TestNumber--)
{
n = Getint();
For(i, , n)
{
Arr[i].x = Getint();
Arr[i].y = Getint();
}
Solve();
}
} inline LL Sqr(int x) {
return 1LL * x * x;
} inline int Multi(const Point &O, const Point &A, const Point &B)
{
int X1 = A.x - O.x, X2 = B.x - O.x, Y1 = A.y - O.y, Y2 = B.y - O.y;
return X1 * Y2 - X2 * Y1;
} inline LL GetDist(const Point &A, const Point &B)
{
return Sqr(B.x - A.x) + Sqr(B.y - A.y);
} inline bool Compare(const Point &A, const Point &B)
{
int Det = Multi(Arr[], A, B);
if(Det) return Det > ;
LL Dist1 = GetDist(Arr[], A), Dist2 = GetDist(Arr[], B);
return Dist1 < Dist2;
} inline void Solve()
{
For(i, , n)
if(Arr[i].x < Arr[].x || (Arr[i].x == Arr[].x && Arr[i].y < Arr[].y))
swap(Arr[i], Arr[]);
sort(Arr + , Arr + + n, Compare); Arr[n + ] = Arr[], Arr[n + ] = Arr[];
bool Flag = ;
int Tmp, Dist;
For(i, , n)
{
int Det = Multi(Arr[i], Arr[i + ], Arr[i + ]);
LL Dist1 = GetDist(Arr[i], Arr[i + ]);
LL Dist2 = GetDist(Arr[i + ], Arr[i + ]);
if(Det <= || Dist1 != Dist2)
{
puts("NO");
return ;
}
if(Flag)
{
if(Tmp != Det || Dist1 != Dist)
{
puts("NO");
return ;
}
}
else Flag = , Tmp = Det, Dist = Dist1;
}
puts("YES");
} int main()
{
Input();
//Solve();
return ;
}
2015ACM/ICPC亚洲区长春站 G hdu 5533 Dancing Stars on Me的更多相关文章
- 2015ACM/ICPC亚洲区长春站 F hdu 5533 Almost Sorted Array
Almost Sorted Array Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Ot ...
- 2015ACM/ICPC亚洲区长春站 B hdu 5528 Count a * b
Count a * b Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Tot ...
- 2015ACM/ICPC亚洲区长春站 L hdu 5538 House Building
House Building Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) ...
- 2015ACM/ICPC亚洲区长春站 J hdu 5536 Chip Factory
Chip Factory Time Limit: 18000/9000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)T ...
- 2015ACM/ICPC亚洲区长春站 H hdu 5534 Partial Tree
Partial Tree Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)To ...
- 2015ACM/ICPC亚洲区长春站 E hdu 5531 Rebuild
Rebuild Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total S ...
- 2015ACM/ICPC亚洲区长春站 A hdu 5527 Too Rich
Too Rich Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total ...
- hdu 5533 Dancing Stars on Me(数学,水)
Problem Description The sky was brushed clean by the wind and the stars were cold in a black sky. Wh ...
- hdu 5533 Dancing Stars on Me
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5533 Dancing Stars on Me Time Limit: 2000/1000 MS (Ja ...
随机推荐
- Unable to execute dex: Multiple dex files define
这是一个编译错误,在ADT的编译器和SDK的工具有差异或是版本不一致时常会出现的一个问题,解决的方案如下: 第一步: updated eclipse (Help->Check for updat ...
- DCMTK开源库的学习笔记4:利用ini配置文件对dcm影像进行归档
转:http://blog.csdn.net/zssureqh/article/details/8846337 背景介绍: 医学影像PACS工作站的服务端需要对大量的dcm文件进行归档,写入数据库处理 ...
- wireshark http抓包命令行详解
This article is a quick and easy HowTo detailing the use of Wireshark or another network sniffing pr ...
- 《ASP.NET1200例》实现投票的用户控件
用户控件ascx <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="24 ...
- PHP 调试用函数
2014年7月4日 10:27:59 有些系统函数可以在调试程序时救急用: get_class_methods(); get_class_vars(); get_object_vars(); get_ ...
- ext树表+ZeroClipboard复制链接功能
效果图:
- WebService之CXF框架
本文主要包括以下内容 ant工具的使用 利用cxf实现webservice cxf与spring整合 ajax访问webservice ant 工具 1.为什么要用到ant这个工具呢? Ant做为一种 ...
- 按键的使用方法(三)-------verilog
按键的使用方法三:一键三用: 点击.长击和双击. 代码: /********************************Copyright***************************** ...
- android之WakeLock机制浅析
转自:http://blog.sina.com.cn/s/blog_4ad7c2540101n2k2.html 应用程序耗电的实质,是所启用的硬件在消耗电量. 手机的耗电单元 CPU: 应用处理器( ...
- 用PHP实现定时器功能
1.直接使用PHP来完成定时 <?php ignore_user_abort(false);//当用户关闭页面时服务停止 set_time_limit(0); //设置执行时间,单位是秒.0表示 ...