题意:给定点A[0~n-1]和B[0],B[1],A[0]、A[1]映射到B[0]、B[1],求出其余点的映射B[2]~B[n-1]。

析:运用复数类,关键是用模板复数类,一直编译不过,我明明能编译过,交上就不过,只能写一个复数了。。。

代码如下:

#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
using namespace std ;
typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f3f;
const int maxn = 10000 + 5;
template<class T>
class Complex
{
public:
Complex( ){real=0;imag=0;}
Complex(T r,T i){real=r;imag=i;}
Complex complex_add(Complex &c2);
Complex complex_minus(Complex &c2);
Complex complex_multiply(Complex &c2);
Complex complex_divide(Complex &c2);
T real1();
T imag1(); public:
friend istream &operator >>(istream &is, Complex<T> &p){
cin >> p.real >> p.imag;
return is;
} private:
T real;
T imag;
}; template<class T>
Complex<T> Complex<T>::complex_add(Complex<T> &c2)
{
Complex<T> c;
c.real=real+c2.real;
c.imag=imag+c2.imag;
return c;
} template <class T>
Complex<T> Complex<T>::complex_minus(Complex <T> &c2)
{
Complex <T> c;
c.real=real-c2.real;
c.imag=imag-c2.imag;
return c;
} template <class T>
Complex<T> Complex<T>::complex_multiply(Complex <T> &c2)
{
Complex <T> c;
c.real=real*c2.real-imag*c2.imag;
c.imag=imag*c2.real+real*c2.imag;
return c;
} template <class T>
Complex<T> Complex<T>::complex_divide(Complex <T> &c2)
{
Complex <T> c;
T d=c2.real*c2.real+c2.imag*c2.imag;
c.real=(real*c2.real+imag*c2.imag)/d;
c.imag=(imag*c2.real-real*c2.imag)/d;
return c;
} template <class T>
T Complex<T>::real1(){
return real;
} template <class T>
T Complex<T>::imag1(){
return imag;
} Complex<double> a[maxn], b[2], ans; int main(){
int T, n; cin >> T;
for(int kase = 1; kase <= T; ++kase){
scanf("%d", &n);
double x, y;
for(int i = 0; i < n; ++i){
cin >> a[i]; }
for(int i = 0; i < 2; ++i){
cin >> b[i];
} Complex<double> tmp = (b[1].complex_minus(b[0]));
Complex<double> tmp1 = (a[1].complex_minus(a[0]));
tmp = tmp.complex_divide(tmp1);
printf("Case %d:\n", kase);
for(int i = 0; i < n; ++i){
ans = (a[i].complex_minus(a[0]));
ans = ans.complex_multiply(tmp);
ans = ans.complex_add(b[0]);
printf("%.2lf %.2lf\n", ans.real1(), ans.imag1());
}
}
return 0;
}
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <complex>
using namespace std ;
typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f3f;
const int maxn = 10000 + 5;
complex<double> a[maxn], b[2], ans; int main(){
int T, n; cin >> T;
for(int kase = 1; kase <= T; ++kase){
scanf("%d", &n);
for(int i = 0; i < n; ++i)
scanf("%lf %lf", &a[i].real(), &a[i].imag());
scanf("%lf %lf %lf %lf", &b[0].real(), &b[0].imag(), &b[1].real(), &b[1].imag());
complex<double> tmp = (b[1]-b[0])/(a[1]-a[0]);
printf("Case %d:\n", kase);
for(int i = 0; i < n; ++i){
ans = (a[i]-a[0]) * tmp + b[0];
printf("%.2lf %.2lf\n", ans.real(), ans.imag());
}
}
return 0;
}

HDU 3365 New Ground (计算几何)的更多相关文章

  1. HDU 5130 Signal Interference(计算几何 + 模板)

    HDU 5130 Signal Interference(计算几何 + 模板) 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=5130 Descripti ...

  2. HDU 4063 Aircraft(计算几何)(The 36th ACM/ICPC Asia Regional Fuzhou Site —— Online Contest)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4063 Description You are playing a flying game. In th ...

  3. hdu 1348:Wall(计算几何,求凸包周长)

    Wall Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submis ...

  4. hdu 1174:爆头(计算几何,三维叉积求点到线的距离)

    爆头 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submissi ...

  5. HDU 5979 Convex【计算几何】 (2016ACM/ICPC亚洲区大连站)

    Convex Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Subm ...

  6. hdu 4631Sad Love Story<计算几何>

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=4631 题意:依次给你n个点,每次求出当前点中的最近点对,输出所有最近点对的和: 思路:按照x排序,然后用s ...

  7. HDU 4606 Occupy Cities (计算几何+最短路+最小路径覆盖)

    转载请注明出处,谢谢http://blog.csdn.net/ACM_cxlove?viewmode=contents    by---cxlove 题目:给出n个城市需要去占领,有m条线段是障碍物, ...

  8. 2017 Multi-University Training Contest - Team 9 1003&&HDU 6163 CSGO【计算几何】

    CSGO Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Subm ...

  9. HDU 5839 Special Tetrahedron 计算几何

    Special Tetrahedron 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5839 Description Given n points ...

随机推荐

  1. FastAdmin 后台 UserRule 勾选不完整 Bug 修复

    FastAdmin 后台 UserRule 勾选不完整 Bug 修复 当用户权限的级选择时出现有部分没有选中. 修复来自在 qmit 1 public static function getTreeL ...

  2. 自动工作负载库理论与操作(Automatic Workload Repository,AWR)

    AWR的由来:    10g之前的oracle:用户的连接将产生会话,当前会话记录保存在v$session中:处于等待状态的会话会被复制一份放在v$session_wait中.当该连接 断开后,其原来 ...

  3. 对象的克隆,Dozer的使用

    现在有个复杂对象bean需要在赋值后在另一个地方用,想通过复制的方式拿到这个对象.首选是深度克隆,虽然发现该对象的父类已经实现了Cloneable接口,但父类是通过jar包引入的,而且在clone方法 ...

  4. Restore Nexus 5 to Stock and Flash Factory Images

    1.This is the website to download Factory Images for Nexus Devices https://developers.google.com/and ...

  5. MySQL中的各种引擎

    数据库中的存储引擎其实是对使用了该引擎的表进行某种设置,数据库中的表设定了什么存储引擎,那么该表在数据存储方式.数据更新方式.数据查询性能以及是否支持索引等方面就会有不同的“效果”.在MySQL数据库 ...

  6. 开学初的c

    cout<<a[i]<<" " 这个是先输出a[i]再输出空格 cout<<endl      这个是直接换行cout<<a[i]& ...

  7. CAN总线位仲裁技术

    CAN总线位仲裁技术 只要总线空闲,任何单元都可以开始发送报文. 要对数据进行实时处理,就必须将数据快速传送,这就要求数据的物理传输通路有较高的速度.在几个站同时需要发送数据时,要求快速地进行总线分配 ...

  8. 【转】Jmeter Http请求界面解释

    一个HTTP请求有着许多的配置参数,下面将详细介绍: 名称:本属性用于标识一个取样器,建议使用一个有意义的名称. 注释:对于测试没有任何作用,仅用户记录用户可读的注释信息. 服务器名称或IP :HTT ...

  9. msf上MS-2017-010(Eternalblue)的复现

    目标主机:192.168.220.148,系统为Microsoft Windows Server 2008 R2 Datacenter,开启了445端口 开启msf root@sch01ar:~# m ...

  10. 3.solr学习速成之索引添加 查询 删除

    solrserver.java public class solrServer { private solrServer(){}; final static String SOLR_URL = &qu ...