洛谷 P1227 [JSOI2008]完美的对称
2017-11-05 18:50
661 查看
题目大意:求一些点集的公共对称中心
#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #define N 20009 using namespace std; int n; struct W{ double x,y; }w ; bool cmp(W a,W b){ if(a.x==b.x)return a.y<b.y; return a.x<b.x; } int main(){ scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%lf%lf",&w[i].x,&w[i].y); } sort(w+1,w+n+1,cmp); double xx=(w[1].x+w .x)/2.0; double yy=(w[1].y+w .y)/2.0; for(int i=2;i<=n;i++){ if(n-i+1<=i)break; double tx=(w[i].x+w[n-i+1].x)/2.0; double ty=(w[i].y+w[n-i+1].y)/2.0; if(tx!=xx||ty!=yy){ printf("This is a dangerous situation!\n"); return 0; } } printf("V.I.P. should stay at (%.1lf,%.1lf).",xx,yy); return 0; }View Code
相关文章推荐
- 找规律-洛谷P1227 [JSOI2008]完美的对称
- 洛谷 P1227 [JSOI2008]完美的对称
- [JSOI2008] [洛谷P1227] 完美的对称|乱搞
- [luoguP1227] [JSOI2008]完美的对称(sort)
- 洛谷 P1227 [JSOI2008]完美的对称
- 计算几何瞎暴力——Luogu1227 [JSOI2008]完美的对称
- [JSOI2008]完美的对称{数论}
- 洛谷 P1227 [JSOI2008]完美的对称
- [JSOI2008]完美的对称 题解
- 洛谷P1197 [JSOI2008]星球大战
- 洛谷 P1198 [JSOI2008]最大数
- 并查集【洛谷P1197】 [JSOI2008]星球大战
- 洛谷P1197 [JSOI2008]星球大战(并查集)
- 洛谷 P1198 BZOJ 1012 [JSOI2008]最大数
- bzoj 1015&&洛谷P1197 [JSOI2008]星球大战starwar解题报告
- 【洛谷P1197】[JSOI2008]星球大战 反向并查集+统计连通块
- 洛谷 P1197 [JSOI2008]星球大战
- 洛谷P1197 [JSOI2008]星球大战
- 并查集-洛谷P1197 [JSOI2008]星球大战
- 洛谷:JSOI2008 最大数