链接: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. nginx+lua+redis初体验

    1.下载nginx.lua.redis nginx下载地址 wget  http://nginx.org/download/nginx-1.8.0.tar.gz lua下载地址 wget http:/ ...

  2. QTP动态加载对象库

    Public Function AddObjectRepository(path) On Error Resume Next Dim pos, repath If instr(path,". ...

  3. CentOS安装 Docker

    系统的要求64 位操作系统,内核版本至少为 3.10. Docker 目前支持 CentOS 6.5 及以后的版本,推荐使用 CentOS 7 系统. cat /proc/version 首先,也是要 ...

  4. Git 图解剖析

    git中文件内容并没有真正存储在索引(.git/index)或者提交对象中,而是以blob的形式分别存储在数据库中(.git/objects),并用SHA-1值来校验. 索引文件用识别码列出相关的bl ...

  5. Java基础——多线程

    Java中多线程的应用是非常多的,我们在Java中又该如何去创建线程呢? http://www.jianshu.com/p/40d4c7aebd66 一.常用的有三种方法来创建多线程 新建一个类继承自 ...

  6. 关键字 new 的作用

    ①做运算符 用于创建对象和调用构造函数,小栗子a如下: Class1 obj = new Class1(); 创建匿名类型的实例,小栗子b如下: var query = from cust in cu ...

  7. 高效渲染css

    译自:http://css-tricks.com/efficiently-rendering-css/ 无可否认我并不经常考虑这个问题… 我们书写的CSS的效率如何,浏览器渲染它的速度如何? 浏览器的 ...

  8. poj3122 pie

    方法:二分. 题目意思:要过生日了,我请大家吃pie,然后人数一共是f+1(我自己).每个人的pie不能是拼接的,而且每个人的面积是一样的,这样就用二分枚举. 范围是0-最大的那块pie. 然后用每一 ...

  9. Muzei Live Wallpaper壁纸应用安卓源码项目

    这个刚刚在安卓教程网那里看到的,这个是Muzei Live Wallpaper壁纸应用源码,这是已经在Playstore上线了的android壁纸应用,点击壁纸界面可以磨砂透明效果以及一般背景效果之间 ...

  10. State

    #include <iostream> using namespace std; #define DESTROY_POINTER(ptr) if (ptr) { delete ptr; p ...