题意:给定的这些点是否有一个对称中心。

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 ;
}

最新文章

  1. 在Visual Studio 中开发自定义脚手架 Scaffolder
  2. 关于SQLite的伪随机数
  3. foreach为什么要实现IEnumerable接口而不是直接用IEnumerator接口
  4. 【python】迭代器&amp;生成器
  5. 【hadoop2.6.0】利用Hadoop的 Java API
  6. http://www.cnblogs.com/meiCode/p/5896239.html
  7. KVC和KVO大优点
  8. CentOS 下开启.htaccess
  9. 找做IT的男朋友会不会没有隐私
  10. POJ C程序设计进阶 编程题#4:括号匹配问题
  11. ORACLE 数据库概述以及Oracel数据库的安装、卸载、使用
  12. java StringBuffer与StringBuilder
  13. 从零开始学习jquery (二)
  14. 令人费解的java泛型
  15. 第25月第26天 dispatch_group_t dispatch_semaphore_t
  16. linux 模拟发http请求的例子
  17. 【java】类的初识
  18. 铁乐学python_Day40_进程池
  19. nuget修改配置文件
  20. 判断是否是iPhone5

热门文章

  1. Unity3D项目实战笔记(5):延时功能的几种实现
  2. response.redirect和server.Transfer的差别详解
  3. 《JS高级程序设计》笔记 —— 解析查询字符串
  4. javascript 基础API
  5. Tomcat上配置连接池{ connect error=Name [jdbc/OracleDB] is not bound in this Context. Unable to find [jdbc]}
  6. c#基础------------静态类与非静态类
  7. JavaScript jQuery 入门回顾
  8. 一些dos命令
  9. oracle中的隐式提交(auto commit)
  10. oracle的function和procedure返回值给shell