栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

poj 1859 The Perfect Symmetry

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

poj 1859 The Perfect Symmetry

#include <stdio.h>#include <iostream>#include <algorithm>using namespace std;struct Point {    double x, y;} P[20010], o;int cmp(Point a, Point b) {    if(a.x == b.x)        return a.y < b.y;    return a.x < b.x;}int main(){    int n;    while(~scanf("%d", &n) && n) {        bool flag = true;        for(int i = 1; i <= n; ++i) { scanf("%lf%lf", &P[i].x, &P[i].y);        }        sort(P+1, P+n+1, cmp);        o.x = (P[1].x+P[n].x)/2;        o.y = (P[1].y+P[n].y)/2;        for(int i = 2; i <= n; ++i) { double x = (P[i].x+P[n-i+1].x)/2; double y = (P[i].y+P[n-i+1].y)/2; if(x != o.x || y != o.y) {     flag = false;          break; }        }        if(flag) { printf("V.I.P. should stay at (%.1lf,%.1lf).n", o.x, o.y);        }        else { printf("This is a dangerous situation!n");        }    }    return 0;}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/377650.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号