poj1859The Perfect Symmetry
按x或y排序,假如有对称点的话,头尾相对。
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 100000
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
struct Point
{
double x,y;
Point(double x=,double y=):x(x),y(y) {}
}p[N];
typedef Point pointt;
pointt operator + (Point a,Point b)
{
return Point(a.x+b.x,a.y+b.y);
}
pointt operator - (Point a,Point b)
{
return Point(a.x-b.x,a.y-b.y);
}
int dcmp(double x)
{
if(fabs(x)<eps) return ;
else return x<?-:;
}
bool cmp(Point a,Point b)
{
if(dcmp(a.x-b.x)==)
return a.y<b.y;
return a.x<b.x;
}
int main()
{
int n,i,j;
while(scanf("%d",&n)&&n)
{
for(i = ; i <= n ;i++)
scanf("%lf%lf",&p[i].x,&p[i].y);
sort(p+,p+n+,cmp);
double tx = (p[].x+p[n].x)/,ty = (p[].y+p[n].y)/;
int flag = ;
for(i = ; i <= n; i++)
{
double x = (p[i].x+p[n-i+].x)/;
double y = (p[i].y+p[n-i+].y)/;
if(dcmp(x-tx)!=||dcmp(y-ty)!=)
{
flag = ;
break;
}
}
if(flag)
printf("V.I.P. should stay at (%.1f,%.1f).\n",tx,ty);
else
printf("This is a dangerous situation!\n");
}
return ;
}
poj1859The Perfect Symmetry的更多相关文章
- words
conscious[英][ˈkɒnʃəs][美][ˈkɑnʃəs]consensus[英][kənˈsensəs][美][kənˈsɛnsəs] scious sensuswaterflood; de ...
- go语言通道详解
https://www.ardanlabs.com/blog/2017/10/the-behavior-of-channels.html Introduction When I started to ...
- Swift3.0服务端开发(一) 完整示例概述及Perfect环境搭建与配置(服务端+iOS端)
本篇博客算是一个开头,接下来会持续更新使用Swift3.0开发服务端相关的博客.当然,我们使用目前使用Swift开发服务端较为成熟的框架Perfect来实现.Perfect框架是加拿大一个创业团队开发 ...
- [LeetCode] Valid Perfect Square 检验完全平方数
Given a positive integer num, write a function which returns True if num is a perfect square else Fa ...
- [LeetCode] Perfect Squares 完全平方数
Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 1 ...
- C++: Perfect Forwarding
Link: Rvalue References and Perfect Forwarding in C++0x (https://www.justsoftwaresolutions.co.uk/cpl ...
- How to write perfect C code
Several days ago, I was involved in an argument about choice of C or C++. What I ignored was "l ...
- POJ1274 The Perfect Stall[二分图最大匹配]
The Perfect Stall Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 23911 Accepted: 106 ...
- 【leetcode】Perfect Squares (#279)
Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 1 ...
随机推荐
- C#:写日志
一.直接写入文件 /// <summary> /// 将message的内容写入日志文件 /// </summary> /// <param name="msg ...
- 查看mysql的状态
实时查看mysql状态连接数 查询数 etc mysqladmin -uroot -p '' -h status -i 1
- SlickGrid example 3b: 支持撤销操作的编辑单元
不同类型的属性可以按不同的风格编辑. 每个编辑单元可以设置不同的验证方法. 历史编辑可以撤销. 代码: <!DOCTYPE html PUBLIC "-//W3C//DTD HTM ...
- Session案例:简易的购物车
三个jsp和两个Servlet组成:在WebContent下边建立一个shoppingcart文件夹,将三个jsp文件放在里面: 1.建立一个step1.jsp文件,出现一个表格,是一个复选框,可以选 ...
- MySQL 数据库发展历程及缺点
传统关系数据库的瓶颈 传统的关系数据库具有不错的性能,高稳定型,久经历史考验,而且使用简单,功能强大,同时也积累了大量的成功案例.在互联网领域,MySQL成为了绝对靠前的王者,毫不夸张的说,MySQL ...
- JAVA学习随笔-.class
类名.class是获得这个类所对应的Class实例.从面向对象的角度上来看,类也是对象,它们是类这个类对象,听起来有些抽象,但是在java中的实现就是所有的加载进来的类在虚拟机中都是一个java.la ...
- Bootstrap——基本模板
<!DOCTYPE html><html lang="zh-cn"> <head> <meta charset="utf ...
- XML 增删改查
<?php $xmlpatch = 'index.xml'; $_id = '; $_title = 'title1'; $_content = 'content1'; $_author = ' ...
- 多态,虚拟方法,重写,接口,类库,委托,is,as运算符,泛型集合,万能变量
多态:简而言之就是龙生九子,各有不同 有了继承,才有了多态 1.虚方法 virtual重写 override父类中的方法,在子类中并不适用,那么子类需要自主更改继承的方法或者是属性,那父类中加了vir ...
- #define用法集锦
Definition: The #define Directive You can use the #define directive to give a meaningful name to a c ...