hdu 5533 Dancing Stars on Me(水)
2015-11-02 10:35
369 查看
题目链接:hdu 5533 Dancing Stars on Me
解题思路
只有n=4时才有可能。代码
#include <cstdio> #include <cstring> #include <vector> #include <algorithm> using namespace std; const int maxn = 105; struct Point { int x, y; Point (int x = 0, int y = 0): x(x), y(y) {} void read() { scanf("%d%d", &x, &y); } bool operator == (const Point& u) const { return x == u.x && y == u.y; } bool operator < (const Point& u) const { return x < u.x || (x == u.x && y < u.y); } Point operator + (const Point& u) const { return Point(x + u.x, y + u.y); } int operator * (const Point& u) const { return x * u.x + y * u.y; } int operator ^ (const Point& u) const { return x * u.y - y * u.x; } }; int N; Point P[maxn]; bool judge () { if (N != 4) return false; vector<int> g; g.clear(); for (int i = 0; i < N; i++) { for (int j = i + 1; j < N; j++) { int x = P[i].x - P[j].x; int y = P[i].y - P[j].y; g.push_back(x * x + y * y); } } sort(g.begin(), g.end()); for (int i = 1; i < 4; i++) if (g[i] != g[0]) return false; return g[4] == g[5]; } int main () { int cas; scanf("%d", &cas); while (cas--) { scanf("%d", &N); for (int i = 0; i < N; i++) P[i].read(); printf("%s\n", judge() ? "YES" : "NO"); } return 0; }
相关文章推荐
- MSTest or TRX to HTML with Animated Charts
- iOS自定义cell的写法
- java 写出和读入 Object对象
- Quick Start Guide for Apache Hawq[作者:盛想]
- python实现机器学习之决策树
- OpenMP多线程编程实验
- 关于vcard通讯录格式解析
- spring mvc +cookie+拦截器功能 实现系统自动登陆
- Mybatis循环map的一些技巧
- Tomcat中文乱码问题的原理和解决方法
- iOS之CocoaPods使用
- Android 动态库死机调试方法
- ios应用:release与debug编译方式的区别
- php操作mysql获取html标签<select>下拉列表数据
- tomcat
- 使用同一类保存不同数据
- mac终端打开出现问题:[forkpty: Resource temporarily unavailable]
- 求主元素
- LeetCode68——Text Justification
- [Python开发] python使用nltk进行Chart Parsing