hdu 5533 Dancing Stars on Me 水题
2015-11-11 14:40
453 查看
[b]Dancing Stars on Me[/b]
Time Limit: 20 SecMemory Limit: 256 MB
题目连接
http://acm.hdu.edu.cn/showproblem.php?pid=5533Description
The sky was brushed clean by the wind and the stars were cold in a black sky. What a wonderful night. You observed that, sometimes the stars can form a regular polygon in the sky if we connect them properly. You want to record these moments by your smart camera. Of course, you cannot stay awake all night for capturing. So you decide to write a program running on the smart camera to check whether the stars can form a regular polygon and capture these moments automatically.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. If you touch a buoy before your opponent, you will get one point. For example if your opponent touch the buoy #2 before you after start, he will score one point. So when you touch the buoy #2, you won't get any point. Meanwhile, you cannot touch buoy #3 or any other buoys before touching the buoy #2.
⋅2. Ignoring the buoys and relying on dogfighting to get point.
If you and your opponent meet in the same position, you can try to
fight with your opponent to score one point. For the proposal of game
balance, two players are not allowed to fight before buoy #2 is touched by anybody.
There are three types of players.
Speeder:
As a player specializing in high speed movement, he/she tries to avoid
dogfighting while attempting to gain points by touching buoys.
Fighter:
As a player specializing in dogfighting, he/she always tries to fight
with the opponent to score points. Since a fighter is slower than a
speeder, it's difficult for him/her to score points by touching buoys
when the opponent is a speeder.
All-Rounder: A balanced player between Fighter and Speeder.
There will be a training match between Asuka (All-Rounder) and Shion (Speeder).
Since the match is only a training match, the rules are simplified: the game will end after the buoy #1 is touched by anybody. Shion is a speed lover, and his strategy is very simple: touch buoy #2,#3,#4,#1 along the shortest path.
Asuka is good at dogfighting, so she will always score one point by dogfighting with Shion, and the opponent will be stunned for T seconds after dogfighting.
Since Asuka is slower than Shion, she decides to fight with Shion for
only one time during the match. It is also assumed that if Asuka and
Shion touch the buoy in the same time, the point will be given to Asuka
and Asuka could also fight with Shion at the buoy. We assume that in
such scenario, the dogfighting must happen after the buoy is touched by
Asuka or Shion.
The speed of Asuka is V1 m/s. The speed of Shion is V2 m/s. Is there any possibility for Asuka to win the match (to have higher score)?
[b]Input[/b]
The first line contains a integer T indicating the total number of test cases. Each test case begins with an integer n, denoting the number of stars in the sky. Following n lines, each contains 2 integers xi,yi, describe the coordinates of n stars.
1≤T≤300
3≤n≤100
−10000≤xi,yi≤10000
All coordinates are distinct.
[b]Output[/b]
For each test case, please output "`YES`" if the stars can form a regular polygon. Otherwise, output "`NO`" (both without quotes).
[b]Sample Input[/b]
3 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
[b]Sample Output[/b]
NO YES NO
HINT
[b]题意[/b]
给你n个整数点,然后问你是否这几个点能够构成一个正多边形
[b]题解:[/b]
只用考虑n=4的情况,然后判断是否为一个正方形就好了
然后瞎搞一波。。。
[b]代码[/b]
#include<iostream> #include<stdio.h> #include<algorithm> #include<cstring> using namespace std; pair<int,int> p[302]; int check() { sort(p,p+4); vector<int>G; for(int i=0;i<4;i++) for(int j=i+1;j<4;j++) { int x = p[i].first - p[j].first; int y = p[i].second - p[j].second; G.push_back((x*x)+(y*y)); } sort(G.begin(),G.end()); for(int i=1;i<4;i++) if(G[i]!=G[i-1]) return 0; if(G[4]==G[3])return 0; if(G[5]!=G[4])return 0; return 1; } int main() { int t;scanf("%d",&t); while(t--) { int n;scanf("%d",&n); for(int i=0;i<n;i++) scanf("%d%d",&p[i].first,&p[i].second); if(n!=4) { printf("NO\n");continue; } sort(p,p+4); if(check())printf("YES\n"); else printf("NO\n"); } }
相关文章推荐
- spring mvc文件上传和下载
- php+mysql实现无限级分类
- 完全背包问题 打印背包中的物品
- ExtJs4 基础必备
- zoj 2975 Kinds of Fuwas
- shell date处理
- node-readability不能正常工作
- 反向传播神经网络极简入门
- 结构体、共用体简单比较
- AWK用户自定义函数
- ASIHTTPRequest
- Activity 在本地进程的创建流程,已经动画
- 程序异常动手动脑整理
- UML图基本类型
- SharePoint Config database Log file too big – reduce it!
- Android 动画
- sublime快捷键整理
- subString() jdk1.7改进
- α_β_γ_δ_ε_ζ_η_θ_ι_κ_λ_μ_ν怎么读
- semver语义化版本号