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 ...
随机推荐
- js 字符串比较
<script type="text/javascript"> function test(){ //1)纯数字之间比较 //alert(1<3);//true ...
- VS中遇到的奇怪问题
8.错误 C2440: “static_cast”: 无法从“void (__thiscall CView::* )(UINT,LONG)”转换为“LRESULT (__thiscall CWnd:: ...
- js比typeof更准确的验证类型方法
var type = function (o){ var s = Object.prototype.toString.call(o); return s.match(/\[object (.*?)\] ...
- 【转】表删除时 Cannot delete or update a parent row: a foreign key constraint fails 异常处理
转载地址:http://lijiejava.iteye.com/blog/790478 有两张表,结构如下: t_item: t_bid: id ...
- Session机制(是对cookie的作用的提升,使用较多)
1.Session作用类似于购物车,第一次,放入物品,可以获得Session的id,并可以设置id失效的时间,这样便于多次将物品放在购物车里面,使用的就是获取的Session的id: 2.Sessio ...
- 2015-11-04 报表(c#部分)(Datatable 查询,弹出日期控件,输入是否整数)
using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq ...
- 实现Fragment的切换和ViewPager自动循环设置切换时间
1.FragmentActivity与Fragment之间的用法 2.实现ViewPager自动轮换,设置移动的时间 通过反射获取mScrooler这个对象: Field mScroller; mSc ...
- 如何在 Eclipse 中连接源码
1:首先在window 中 打开首选项(preferences) 找到如下java -- 已安装的JRE
- Unity中实现List类型的自定义GUI(ReorderableList)
感谢韩同学提供的资源 Unity本身提供了float,int,vector3..等类型字段的gui接口,而对于集合类型一般要自己硬写. 官方提供了一个List的自定义GUI,但使用起来非常复杂 Uni ...
- #ifdef _DEBUG
#ifdef _DEBUG virtual void AssertValid() const; //assert(断言)valid(有效的,正确的) virtual void Dump(CDumpCo ...