链接: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. python-appium练习编写脚本时遇到问题

    遇到问题: 1.安卓4.2及以下系统无法识别resource-id属性 只能用text属性识别 2.输入中文无法识别 脚本最顶部增加#coding=utf-8 3.对象无法识别resource-id属 ...

  2. Unity Shader : Ghost(残影) v1

    前阵子组长给我提了个需求,要实现角色人物的残影.我百度google了一下,发现可以用两种方式实现这个效果:1.记录前几帧的人物位置,将其传入shader中,对每个位置进行一个pass渲染.2. 通过相 ...

  3. C/C++程序员面试易错题

    c部分::::::::::::::::::::::::::::::::::: . 关键字volatile有什么含意? 并给出三个不同的例 子. [参考答案]一个定义为volatile的变量是说这变量可 ...

  4. Virtualenv介绍

    [翻译]http://virtualenv.readthedocs.org/en/latest/index.html virtualenv是创建独立python环境的一种工具. 环境搭建的过程中,有一 ...

  5. Adobe AIR and Flex - 实现堆栈容器

    1.需求描述: 在对云平台的监控中,我们经常需要在一张图上可视化的描述集群下的物理机所虚拟的虚拟机使用情况,以及超卖情况.那么传统的chart图就不满足我们的需求了,那么要实现这样一个定制化的char ...

  6. redis学习(3)redis.conf配置文件详解

    # Redis 配置文件 # 当配置中需要配置内存大小时,可以使用 1k, 5GB, 4M 等类似的格式,其转换方式如下(不区分大小写) # # 1k =>  1000 bytes # 1kb ...

  7. 处理SVN的提交代码冲突

    工具: 一台开发的电脑,myeclipse,TortoiseSVN1.8 步骤: 1.不管是提交.更新.编辑冲突第一个操作都应该是和资源库进行同步,项目右键==>Team==>于资源库同步 ...

  8. SQL Access Advisor

    1.概述: provides advice on improving the performance of a database through partitioning, materialized ...

  9. Andriod项目开发实战(2)——JSON和XML的区别

    详情见: 1.http://www.cnblogs.com/SanMaoSpace/p/3139186.html 2.http://www.cnblogs.com/yank/p/4028266.htm ...

  10. Collection集合之六大接口(Collection、Set、List、Map、Iterator和Comparable)

    首先,我们先看一下Collection集合的基本结构: 1.Collection接口 Collection是最基本集合接口,它定义了一组允许重复的对象.Collection接口派生了两个子接口Set和 ...