HDU 5533 Dancing Stars on Me [数学]
来源:互联网 发布:抽风解说 知乎 编辑:程序博客网 时间:2024/05/20 02:30
2015区域赛 长春赛区 G题
Description
给N个格点,问能否组成正多边形
Algorithm
格点正多边形形只能是正方形
格点 百度百科
既然如此,N != 4就直接再见
然后6条边长度必定是4条相等,另外两条根号2,排序,判断一下就是了
Code
#include <cstdio>#include <cmath>#include <algorithm>using namespace std;struct P{ int x, y;};double dist(const P &a, const P &b){ return pow(a.x - b.x, 2) + pow(a.y - b.y, 2);}bool solve(){ int n; scanf("%d", &n); if (n != 4) { int x, y; for (int i = 0;i < n; i++) scanf("%d%d", &x, &y); return false; } P a[4]; for (int i = 0; i < n; i++) scanf("%d%d", &a[i].x, &a[i].y); double d[6]; int k = 0; for (int i = 0; i < n; i++) for (int j = 0; j < i; j++) d[k++] = dist(a[i], a[j]); sort(d, d+k); if (d[0] == d[1] && d[1] == d[2] && d[2] == d[3] && d[4] == d[5] && d[4] == d[3] * 2) return true; return false;}int main(){ int t = 1; scanf("%d", &t); for (int i = 0; i < t; i++) solve() ? puts("YES") : puts("NO"); return 0;}
0 0
- HDU 5533:Dancing Stars on Me【数学】
- HDU 5533 Dancing Stars on Me [数学]
- HDU 5533 Dancing Stars on Me(数学+水题)
- hdoj 5533 Dancing Stars on Me【数学】
- hdu 5533 Dancing Stars on Me
- hdu 5533 Dancing Stars on Me
- HDU 5533 Dancing Stars on Me
- hdu 5533 Dancing Stars on Me
- HDU 5533 Dancing Stars on Me
- HDU 5533 Dancing Stars on Me
- HDU-5533 Dancing stars on me
- HDU Dancing Stars on Me
- Dancing Stars on Me HDU
- hdoj Dancing Stars on Me 5533 (数学几何&&技巧)
- HDU杭电5533 Dancing Stars on Me
- hdu 5533 Dancing Stars on Me(水)
- HDU 5533 Dancing Stars on Me(凸包)
- HDU-5533-Dancing Stars on Me【2015长春赛区】
- 回顾过去展望未来之2015
- ZOJ 3713 10th省赛 I In 7-bit【位运算】
- Collections.synchronizedList()不同锁造成的陷阱
- Data Binding 打造RecyclerView 万能适配器
- 用宏定义的形式书写代码块
- HDU 5533 Dancing Stars on Me [数学]
- HDU 5289 Assignment(2015 Multi-University Training Contest 1)
- 黄菡经典语录
- linux的root密码忘了解决办法
- Carmichael Numbers uva10006
- Android远程服务——AIDL
- Windows-Git和Github管理自己代码
- Oracle db 重做日志
- /etc/profile 和 ~/.profile 区别是全部用户,和单一用户