Unstable

题目连接:

http://acm.hdu.edu.cn/showproblem.php?pid=5295

Description

Rasen had lost in labyrinth for 20 years. In a normal day, he found a bright screen. There were 4 points labeled by ‘A’ , ‘B’ , ‘C’ , ‘D’, and rasen could drag these point. And two points ‘E’ , ‘F’ moved. Rasen found that ‘E’ is the middle point of ‘A’ and ‘B’, and ‘F’ is the middle point of ‘C’ and ‘D’. Near the screen there was a marble slab.There were a list of the distance of AB , BC , CD , DA and EF. Rasen also found that the distance of these edge of the points in screen showed at the same time he drop the points. He wanted to know what will happen if the distances in screen are same with the number in slab.

Input

The first line of input contains only one integer T(<=50000), the number of test cases.

Each case contains five float number, indicating the distance of AB , BC , CD , DA , EF.(0<=distance<=10000)

Output

For each test, first print a line “Case #i:”(without quotes),with i implying the case number, then output the coordinates of A,B,C,D four points. Answer will be considered as correct if the length got from your output (the spj will use double to get the point, and the distance from two points will calculate in the way of sqrt((x1-x2)^2 +(y1-y2)^2) ) and the length given is less than 10-4.

(It guarantees that there exists a solution. If there are many solutions, output any one of them.)

Sample Input

1

1.000000 1.000000 1.000000 1.000000 1.000000

Sample Output

Case #1:

0.000000 0.000000

1.000000 0.000000

1.000000 1.000000

0.000000 1.000000

Hint

题意

平面上有四个点A,B,C,D

然后告诉你AB,BC,CD,DA长度,然后E是AB中点,F是CD中点,EF的长度你也知道。

现在你需要构造一组解,使得满足要求。

题解:

随便画个四边形,然后延长AF到A‘,使得A’F=AF,做AB的平行线DG,使得DG=AB。

然后连接A'C,A'B,A'G,CG

显然的发现三角形DFA全等于三角形FCA',三角形AFE相似于三角形ABA'

然后A‘就是以C点为圆心,AC为半径和B点为圆心,BA'为半径的圆相交的交点。

知道A’之后,G点可以由CA'+CB得到。

然后D点坐标就是以G为圆心,AB为半径,C为圆心,CD为半径的交点。

然后A点就瞎搞就好了。

然后就完了。

代码

#include<bits/stdc++.h>
using namespace std;
struct POINT
{
double x;
double y;
POINT(double a=0, double b=0) { x=a; y=b;} //constructor
};
void c2point(POINT p1,double r1,POINT p2,double r2,POINT &rp1,POINT &rp2)
{
if(fabs(p1.x-p2.x)<1e-6&&fabs(p1.y-p2.y)<1e-6&&fabs(r1-r2)<1e-6)
{
rp1.x=p1.x;
rp1.y=p1.y+r1;
rp2.x=p1.x;
rp2.y=p1.y-r1;
return;
}
double a,b,r;
a=p2.x-p1.x;
b=p2.y-p1.y;
r=(a*a+b*b+r1*r1-r2*r2)/2;
if(fabs(a)<1e-6&&fabs(b)>1e-6)
{
rp1.x=rp2.x=r/b;
double tmp = r1*r1-rp1.x*rp1.x;
if(tmp<0)tmp=0;
rp1.y=sqrt(tmp);
rp2.y=-rp1.y;
}
else if(fabs(a)>1e-6&&fabs(b)<1e-6)
{
rp1.x=rp2.x=r/a;
double tmp = r1*r1-rp1.x*rp2.x;
if(tmp<0)tmp=0;
rp1.y=sqrt(tmp);
rp2.y=-rp1.y;
}
else if(fabs(a)>1e-6&&fabs(b)>1e-6)
{
double delta;
delta=b*b*r*r-(a*a+b*b)*(r*r-r1*r1*a*a);
if(delta<0)delta=0;
rp1.y=(b*r+sqrt(delta))/(a*a+b*b);
rp2.y=(b*r-sqrt(delta))/(a*a+b*b);
rp1.x=(r-b*rp1.y)/a;
rp2.x=(r-b*rp2.y)/a;
} rp1.x+=p1.x;
rp1.y+=p1.y;
rp2.x+=p1.x;
rp2.y+=p1.y;
}
void solve(int Cas)
{
double ab,bc,cd,da,ef;
scanf("%lf %lf %lf %lf %lf",&ab,&bc,&cd,&da,&ef);
POINT A,B,C,D,E,F,G,A1;
C.x=0,C.y=0;
B.x=bc,B.y=0;
POINT tmp1,tmp2; c2point(C,da,B,2*ef,tmp1,tmp2); A1=tmp1;
G.x=A1.x+B.x,G.y=A1.y+B.y; c2point(C,cd,G,ab,tmp1,tmp2);
D=tmp1; A.x=D.x+C.x-A1.x;
A.y=D.y+C.y-A1.y; printf("Case #%d:\n",Cas);
printf("%.12f %.12f\n",A.x,A.y);
printf("%.12f %.12f\n",B.x,B.y);
printf("%.12f %.12f\n",C.x,C.y);
printf("%.12f %.12f\n",D.x,D.y);
}
int main()
{
int t;scanf("%d",&t);
for(int i=1;i<=t;i++)solve(i);
return 0;
}

HDU 5295 Unstable 计算几何的更多相关文章

  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 1174 爆头(计算几何)

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

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

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

  5. hdu 4613 Points<计算几何>

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=4613 题意: 判断一个集合中的点能不能由另一个集合中的点,通过平移,旋转,放缩得到~ 思路:先求出集合中的 ...

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

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

  7. hdu 4643(计算几何)

    题意:容易理解 分析:切换的地点为两个基站所在直线的中垂线与两座城市所在直线的交点. 代码实现: #include <cstdio> #include <cmath> #inc ...

  8. hdu 4606 简单计算几何+floyd+最小路径覆盖

    思路:将所有的直线的两个端点和城市混在一起,将能直接到达的两个点连线,求一次floyd最短路径.二分枚举bag容量,然后按给的要先后占领的城市由前向后,把能到一步到达的建一条边.然后求一次最小路径覆盖 ...

  9. hdu 4063 Aircraft(计算几何+最短路)

    不说了...说多了都是泪...从昨天下午一直wa到现在,直到刚刚才让人帮我找到所谓的“bug”,其实也算不上bug... 这个题的思路就是:找出平面上的所有点:所有圆的交点以及所有圆的圆心.然后依次判 ...

随机推荐

  1. iOS中响应者链条-触摸事件,hitTest方法坐标转换

    总体来说,分2个步骤: 一,从上到下寻找合适的控件来处理这个触摸事件.如下图,如果点击了黄色4,则UIApplication -> UIWindow -> 1白色 -> 2橙色 -& ...

  2. redis的备份恢复

    说明:默认rdb方式保存,redis支持主从和哨兵等,但是在某些情况下我们会单机跑,所以有时候我们就会需要设计到备份恢复 环境:原始redis:192.168.1.200 新redis:192.168 ...

  3. MAC 文件被锁定

    从windows拷贝到MAC的文件,有时候会被锁定.右键-简介-已锁定也是灰色的,无法取消: xattr -l 文件名 xattr -d com.apple.FinderInfo 文件名

  4. css的背景图片background

    1.使用背景图片的标签定设置宽高,没有设置的话,也需要用内容来撑开标签. 2.如果对同一个标签分开设置背景图片和颜色,背景颜色一定要写在背景图片后面,不然会被覆盖 <!DOCTYPE html& ...

  5. intellij idea 远程tomcat 调试

    由于在服务器上远程调试风险较高,所以万不得已的情况下 不要这样做.可以本地调试好  再上传到服务器上. 1.关闭防火墙 启动Firewalld,及开机自启. # systemctl start fir ...

  6. POJ 3159 Candies(差分约束+spfa+链式前向星)

    题目链接:http://poj.org/problem?id=3159 题目大意:给n个人派糖果,给出m组数据,每组数据包含A,B,C三个数,意思是A的糖果数比B少的个数不多于C,即B的糖果数 - A ...

  7. 使用CEPH RGW admin ops API 进行用户user AK/SK管理的秘诀

    需求: 云平台面板上需要支持为不同的用户创建不同的RGW 的AK/SK用户秘钥,以完成对象存储的用户隔离,并可以管理bucket和查看bucket容量信息. 分析:查阅CEPH官网文档 S3 API  ...

  8. Effective STL 阅读笔记: Item 4 ~ 5: Call empty instead of checking size() against zero.

    Table of Contents 1 Item 4: Call empty instead of checking size() against zero 2 Item 5: Prefer rang ...

  9. DNS区域传送漏洞的安全案例

      DNS区域传送(DNS zone transfer)指的是一台备用服务器使用来自主服务器的数据刷新自己的域(zone)数据库.这为运行中的DNS服务提供了一定的冗余度,其目的是为了防止主的域名服务 ...

  10. 关于HTML5 boilerplate 的一些笔记

    最近在研究HTML5 boilerplate的模版,以此为线索可以有条理地学习一些前端的best practice,好过在W3C的文档汪洋里大海捞针……啊哈哈哈…… 开头的IE探测与no-js类是什么 ...