链接:http://acm.hdu.edu.cn/showproblem.php?pid=4613

题意: 判断一个集合中的点能不能由另一个集合中的点,通过平移,旋转,放缩得到~

思路:先求出集合中的点的凸包,然后枚举每一条边作为起点 ,看原集合中的点能否与要比较的集合中的点一一对应~

 #include <iostream>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <utility>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;
const int maxn = ;
typedef complex<double> point;
#define X real()
#define Y imag()
point p[maxn],s[maxn], tp[maxn],ts[maxn];
double ang;
int cnttp,cntts;
int n,m,M,T;
const double eps = 1e-;
int sign(double x)
{
if(x>eps)return ;
if( fabs(x)>eps )return -;
return ;
} bool cmp(const point& p1,const point& p2)
{
if( sign(p1.X-p2.X)== ) return ( sign( p1.Y-p2.Y)< );
return sign( p1.X-p2.X)<;
} double det(const point &p1,const point& p2,const point& org)
{
return (p1.X - org.X) * (p2.Y - org.Y) - (p1.Y - org.Y) * (p2.X - org.X);
} void graham(int n,point *p,int& s,point *ch)
{
sort(p,p + n,cmp);
int i,s2;
ch[] = p[];s = ;
for(i = ;i < n;i++) {
while(s > && det(p[i],ch[s - ],ch[s - ])<eps)s--;
ch[s++] = p[i];
}
s2 = s;
for(int i = n - ;i>=;i--) {
while(s>s2 && det(p[i],ch[s - ],ch[s - ])<eps)s--;
ch[s++] = p[i];
}
s--;
} double getAngle(const point& p1,const point& p2)
{
double dot = p1.X * p2.X + p1.Y * p2.Y;
dot /= abs(p1) * abs(p2);
return dot;
} bool check(const point& org,const point& trans)
{
for(int i = ;i<m;i++) {
if(!binary_search(p,p + n,(s[i] - org) * trans + tp[],cmp))return false;
}
return true;
} void gao()
{
scanf("%d",&m);
for(int i = ;i<m;i++) {
scanf("%lf%lf",&s[i].X,&s[i].Y);
}
if(n!=m) {puts("No");return;}
if(n<=){puts("Yes");return;}
graham(m,s,cntts,ts);
double sang;
point org,trans;
point A,B,C;
for(int k=; k<=; ++ k){
for(int i = ;i<m;i++)
s[i].X = -s[i].X;
for(int i = ;i<cntts;i++)
ts[i].X = -ts[i].X;
for(int i = ;i<cntts;i++) {
B = ts[i];
A = ts[(cntts + i - ) % cntts];
C = ts[(i + ) % cntts];
sang = getAngle(A - B,C - B);
if(fabs(sang - ang)<eps) {
org = B;
trans = (tp[] - tp[]) / (A - B);
if(check(org,trans)) {
puts("Yes");
return;
}
trans = (tp[] - tp[]) / (C - B);
if(check(org,trans)) {
puts("Yes");
return;
}
}
}
}
puts("No");
return;
} int main()
{
scanf("%d",&T);
while(T--) {
scanf("%d",&n);
for(int i =;i<n;i++) {
scanf("%lf%lf", &p[i].X, &p[i].Y);
}
if(n>) {
graham(n,p,cnttp,tp);
ang = getAngle(tp[] - tp[],tp[cnttp - ] - tp[]);
}
scanf("%d",&M);
for(int i = ;i<M;i++)
gao();
puts("");
}
return ;
}

hdu 4613 Points<计算几何>的更多相关文章

  1. HDU 4998 Rotate (计算几何)

    HDU 4998 Rotate (计算几何) 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=4998 Description Noting is more ...

  2. hdu 4643 GSM 计算几何 - 点线关系

    /* hdu 4643 GSM 计算几何 - 点线关系 N个城市,任意两个城市之间都有沿他们之间直线的铁路 M个基站 问从城市A到城市B需要切换几次基站 当从基站a切换到基站b时,切换的地点就是ab的 ...

  3. hdu 1700 Points on Cycle(坐标旋转)

    http://acm.hdu.edu.cn/showproblem.php?pid=1700 Points on Cycle Time Limit: 1000/1000 MS (Java/Others ...

  4. HDU 5295 Unstable 计算几何

    Unstable 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5295 Description Rasen had lost in labyrint ...

  5. HDU 1700 Points on Cycle (坐标旋转)

    题目链接:HDU 1700 Problem Description There is a cycle with its center on the origin. Now give you a poi ...

  6. HDU 1174 爆头(计算几何)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1174 解题报告:就是用到了三维向量的点积来求点到直线的距离,向量(x1,y1,z1)与(x2,y2,z ...

  7. hdu 1086(计算几何入门题——计算线段交点个数)

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=1086 You can Solve a Geometry Problem too Time Limit: 2 ...

  8. HDU 1700 Points on Cycle (几何 向量旋转)

    http://acm.hdu.edu.cn/showproblem.php?pid=1700 题目大意: 二维平面,一个圆的圆心在原点上.给定圆上的一点A,求另外两点B,C,B.C在圆上,并且三角形A ...

  9. 2017多校第6场 HDU 6097 Mindis 计算几何,圆的反演

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6097 题意:有一个圆心在原点的圆,给定圆的半径,给定P.Q两点坐标(PO=QO,P.Q不在圆外),取圆 ...

随机推荐

  1. Spark Job Scheduling

    最近由于项目需要在研究spark相关的内容,形成了一些技术性文档,发布这记录下,懒得翻译了. There are some spaces the official documents didn't e ...

  2. Flex 仿Winxp左侧菜单

    呆毛放出,源码暂时不能公布,一直比较喜欢winxp的左侧菜单样式,以前也用xslt实现过,但总是达不到完美,没想到FLex轻松做到了这一点,几乎和winxp一模一样.

  3. Firefox下载文件时中文名乱码问题

    为了形象化,先看几张不同浏览器下下载文件时的效果图: 1:Firefox 36.0.1 2:IE8 3:Chrome 40.0.2214.93 m 4:360 7.1.1.322 很明显在Firefo ...

  4. pip的安装及使用

    pip 是“A tool for installing and managing Python packages.”,即pip是python的软件安装工具安装:方法一:(亲自使用)1.去官网下载get ...

  5. prototype原型模式中的问题

    对于每个构造函数来说,都有一个prototype属性.对于每个对象实例来说,都有_proto_属性. 参看下面代码: function Person(){} Person.prototype={ na ...

  6. ionic phonegap translate language demo

    中英文转换,经常用到:而ionic  则是通过angular js 来实现: 用到了 http://www.ng-newsletter.com/posts/angular-translate.html ...

  7. c++ builder TListView控件按字符串排序(根据网上代码亲测ok)

    //--------------------------------------------------------------------------- /* 首先将一个列表框控件安放在Form上, ...

  8. poj3349 哈希

    这题目写了一上午,一直错,然后自己测试数据还都对.为什么呢,为什么呢,后来我才发现代码里有一行free(tmp)...在55行那里... #include <stdio.h> #inclu ...

  9. 为何要使用Linux

    摈弃 Windows 低效率的工作方式,发掘 Linux 身上的 UNIX 气质 我已经半年没有使用 Windows 的方式工作了.Linux 高效的完成了我所有的工作. GNU/Linux 不是每个 ...

  10. 【UEditor】远程上传图片到【七牛云存储】

    杂谈:最近在玩一个第三方的微信开发平台,里面的图片都是上传到[七牛云存储]的,用了一下非常的好用,支持各种语言,SDK齐全.支持全分布式系统架构以及存储技术和数据加速,于是决定将网站的图片都存储到七牛 ...