POJ2526+简单几何
题意:给定的这些点是否有一个对称中心。
PS:我写得有点啰嗦。。
就是把小的x和大的x进行匹配。
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std; const double eps = 1e-;
const int maxn = ; struct Point{
double x,y;
};
Point pnt1[ maxn ],pnt2[ maxn ];
Point cc; int cmp1( Point a,Point b ){
return a.x<b.x;
} int cmp2( Point a,Point b ){
return a.y<b.y;
} int cmp3( Point a,Point b ){
return a.x>b.x;
} bool NotOnePoint( Point a,Point b ){
if( fabs(a.x-b.x)<=eps&&fabs(a.y-b.y)<=eps ) return false;
else return true;
} bool OK( Point a,Point b ){
if( fabs((a.x+b.x)-(2.0*cc.x))<=eps && fabs((a.y+b.y)-(2.0*cc.y))<=eps ) return true;
else return false;
} bool Notcc( Point a ){
if( fabs(a.x-cc.x)<=eps&&fabs(a.y-cc.y)<=eps ) return true;
else return false;
} int main(){
int n;
int T;
//freopen("in.txt","r",stdin);
scanf("%d",&T);
while( T-- ){
scanf("%d",&n);
for( int i=;i<=n;i++ ){
scanf("%lf%lf",&pnt1[i].x,&pnt1[i].y);
pnt2[ i ] = pnt1[ i ];
}
if( n== ){
puts("yes");
continue;
}
sort( pnt1+,pnt1++n,cmp1 );
cc.x = (pnt1[].x+pnt1[n].x)/2.0;
sort( pnt2+,pnt2++n,cmp2 );
cc.y = (pnt2[].y+pnt2[n].y)/2.0;
sort( pnt2+,pnt2++n,cmp3 ); int cnt = ;
if( n%== ){
for( int i=;i<=n;i++ ){
if( pnt1[i].x==cc.x&&pnt1[i].y==cc.y ){
cnt++;
}
}
}
if( (n-cnt)%== ){
puts("no");
continue;
}
if( n==cnt ){
puts("yes");
continue;
}
//printf("cc:x = %lf,y = %lf\n",cc.x,cc.y);
/*
for( int i=1;i<=n;i++ ){
printf("x = %lf \n",pnt1[i].x);
}
for( int i=1;i<=n;i++ ){
printf("x = %lf \n",pnt2[i].x);
}
*/
int tt = ;
int N = n - cnt;//N%2=0
for( int i=;i<=(n/)&&tt<(N/);i++ ){
tt++;
//printf(" i =%d ",i);
//printf("pnt1:x = %lf y = %lf\n",pnt1[i].x,pnt1[i].y);
bool find = false;
for( int j=;j<=(n/);j++ ){
//printf(" j = %d \n",j);
//printf("pnt2:x = %lf y = %lf\n",pnt2[j].x,pnt2[j].y);
if( (pnt1[i].x+pnt2[j].x)<2.0*cc.x ) break;
if( /*Notcc(pnt1[i])==true&&*/NotOnePoint(pnt1[i],pnt2[j])==true&&OK(pnt1[i],pnt2[j])==true ){
find = true;
cnt += ;
break;
}
}
//if( find==true ) printf("true\n");
//else printf("false\n");
if( find==false ) break;
}
if( cnt==n ){
puts("yes");
continue;
}
puts("no");
}
return ;
}
POJ2526+简单几何的更多相关文章
- Python下opencv使用笔记(二)(简单几何图像绘制)
简单几何图像一般包含点.直线.矩阵.圆.椭圆.多边形等等.首先认识一下opencv对像素点的定义. 图像的一个像素点有1或者3个值.对灰度图像有一个灰度值,对彩色图像有3个值组成一个像素值.他们表现出 ...
- Codeforces 935 简单几何求圆心 DP快速幂求与逆元
A #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #def ...
- 简单几何(线段相交) POJ 2653 Pick-up sticks
题目传送门 题意:就是小时候玩的一种游戏,问有多少线段盖在最上面 分析:简单线段相交,队列维护当前最上的线段 /******************************************** ...
- osg for android (一) 简单几何物体的加载与显示
1. 首先需要一个OSG for android的环境. (1).NDK 现在Eclipse 对NDK已经相当友好了,已经不需要另外cygwin的参与,具体可以参考 Android NDK开发篇(一) ...
- HDU 6206 青岛网络赛1001 高精度 简单几何
给出的数据1e12规模,常规判点是否在圆范围内肯定要用到半径,求得过程中无法避免溢出,因此用JAVA自带的浮点大数运算,和个ZZ一样比赛中eclipse出现问题,而且太久没写JAVA语法都不清楚变量忘 ...
- CodeForces 703C Chris and Road (简单几何)
题意:有一个n边形的汽车向以速度v向x轴负方向移动,给出零时时其n个点的坐标.并且有一个人在(0,0)点,可以以最大速度u通过w宽的马路,到达(0,w)点.现在要求人不能碰到汽车,人可以自己调节速度. ...
- Jack Straws POJ - 1127 (简单几何计算 + 并查集)
In the game of Jack Straws, a number of plastic or wooden "straws" are dumped on the table ...
- codeforces 394E Lightbulb for Minister 简单几何
题目链接:点我点我 题意:给定n个点. 以下n行给出这n个点坐标. 给定m个点,以下m行给出这m个点坐标. 这m个点是一个凸包,顺时针给出的. 问:在凸包上随意找一个点(x, y) 使得这个点距离n个 ...
- hdu - 3952 Fruit Ninja(简单几何)
思路来自于:http://www.cnblogs.com/wuyiqi/archive/2011/11/06/2238530.html 枚举两个多边形的两个点组成的直线,判断能与几个多边形相交 因为最 ...
随机推荐
- 接口(interface)
接口(interface) 接口(interface)定义了一个可由类和结构实现的协定.接口可以包含方法.属性.事件和索引器.接口不提供它所定义的成员的实现-它仅指定实现该接口的类或结构必须提供的成员 ...
- (转)实战Memcached缓存系统(3)Memcached配置参数初解
一.基本参数 在我们第一次安装Memcached时,一般都是用过这个命令: memcached -m 512 -u root -d -l 127.0.0.1 -p 11211 我们先来解释这几个参数的 ...
- 【转】Linux杀死fork产生的子进程的僵尸进程defunct
僵尸进程 就是 已经结束,但是还没有清理出去的.用kill -9 $PID 也无法杀死. 所以程序中应该避免出现僵尸进程. 用fork之后,父进程如果没有wait /waitpid 等待子进程的话,子 ...
- 《PHP扩展开发及内核应用》
https://github.com/walu/phpbook/blob/master/preface.md
- netty启动过程
netty先启动work线程,work线程打开selector 绑定pipeline 启动boss线程,绑定端口,注册selector,绑定op_accetp事件 ------------------ ...
- style、currentStyle、getComputedStyle区别介绍
style.currentStyle.getComputedStyle区别介绍 来自:蓝色天空 样式表有三种方式 内嵌样式(inline Style) :是写在Tag里面的,内嵌样式只对所有的Tag有 ...
- redis学习系列
redis学习系列 基本看完 最近在看redis的代码,简单记录下自己认为重要的点,自己写比较费时间的,我会把查到的资料贴出来方便查看 淘宝的redis内存分析 http://www.searchtb ...
- 利用Google GCM发送push通知到Android客户端
// 这个可以需要在google账号中申请,勾选gcm服务选项 $apiKey = 'AIzaSyC6h3ysrn2HDCBqONTo2vKIVVuktIFoxxx'; $headers = arra ...
- 用PHP生成随机数的函数
转自:http://www.jbxue.com/article/5034.html 介绍:在早期的php中生成一个随机字符串时,总是先创建一个字符池,然后用一个循环和mt_rand()或rand()生 ...
- 源码编译安装LAMP环境及配置基于域名访问的多虚拟主机
实验环境及软件版本: CentOS版本: 6.6(2.6.32.-504.el6.x86_64) apache版本: apache2.2.27 mysql版本: Mysql-5.6.23 php版本 ...