2 shunfurh shunfurh 于 2017.08.28 15:46 提问

Euclid

Description

In one of his notebooks, Euclid gave a complex procedure for solving the following problem. With computers, perhaps there is an easier way.

In a 2D plane, consider a line segment AB, another point C which is not collinear with AB, and a triangle DEF. The goal is to find points G and H such that:

H is on the ray AC (it may be closer to A than C or further away, but angle CAB is the same as angle HAB)
ABGH is a parallelogram (AB is parallel to HG, AH is parallel to BG)
The area of parallelogram ABGH is the same as the area of triangle DEF

Input

There will be several test cases. Each test case will consist of twelve real numbers, with no more than 3 decimal places each, on a single line. Those numbers will represent, in order:

AX AY BX BY CX CY DX DY EX EY FX FY

where point A is (AX,AY), point B is (BX,BY), and so on. Points A, B and C are guaranteed to NOT be collinear. Likewise, D, E and F are also guaranteed to be non-collinear. Every number is guaranteed to be in the range from -1000.0 to 1000.0 inclusive. End of the input will be signified by a line with twelve 0.0's.
Output

For each test case, print a single line with four decimal numbers. These represent points G and H, like this:

GX GY HX HY

where point G is (GX,GY) and point H is (HX,HY). Print all values rounded to 3 decimal places of precision (NOT truncated). Print a single space between numbers. Do not print any blank lines between answers.
Sample Input

0 0 5 0 0 5 3 2 7 2 0 4
1.3 2.6 12.1 4.5 8.1 13.7 2.2 0.1 9.8 6.6 1.9 6.7
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
Sample Output

5.000 0.800 0.000 0.800
13.756 7.204 2.956 5.304

1个回答

caozhy
caozhy   Ds   Rxr 2017.09.11 23:43
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
Euclid开源源码解析
项目地址https://github.com/Yalantis/Euclid依赖:CircularReveal            ListViewAnimations理解这个效果一定要看明白xml布局里每个元素直接的关系,以及每个元素在Z轴上的层次关系。<!-- 灵活的使用相对布局--> <RelativeLayout xmlns:android="http://schemas.andro
求最大公约数的欧几里德算法(Euclid's Algorithm)
 求最大公约数的欧几里德算法(Euclids Algorithm)算法主要基于两条规则:1.If b|a then gcd(a, b) = b.2.If a = bt + r, for integers t and r, then gcd(a, b) = gcd(b, r).定理gcd(a,b) = gcd(b,a mod b)例如:Let a = 2322, b = 654. 2322 =
HDU1525 Euclid's Game (找规律博弈)
Euclid's Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3434    Accepted Submission(s): 1599 Problem Description Two players,
Intel Euclid (一)
Intel Euclid
Euclid空间上的点集划分
定义 ∀S⊆Rn,∀x⃗ ∈Rn,x⃗ \forall S \subseteq R^n, \forall \vec{x} \in R^n, \vec{x} 是 SS 的 内点: ∃δ>0,∀x∈N(x⃗ ,δ),x∈S\exists \delta > 0, \forall x \in N(\vec{x}, \delta), x \in S 外点: ∃δ>0,∀x∈N(x⃗ ,δ),x∉S\e
uva 10368 - Euclid's Game(博弈)
题目链接:uva 10368 - Euclid's Game 题目大意:给出两个数,两个人做一个游戏,每次有stan开始操作,每次操作可以从最大的数中取走若干个小的数,即a-kb,a为比较大的数,b为比较小的数,kb为取走的值,k必须为整数,并且kb≤a。如果不能顺利执行操作,则对手胜利。 解题思路:模拟,直到k的最大值不为1时,当前操作者就掌握了主动权,既可以获胜。特殊情况为a=b的
Euclid 算法
今天在看RSA加密算法的时候看到了可以用扩充的euclid算法来简化d的计算。一查才发现原来euclid算法算法就是下面这个式子: GCED (a, b) = GCED (b, a % b)下面这个是著名求最大公约数的辗转相除算法的代码实现:int Euclid_Algorithm (int m, int n){        int temp =
euclid's algorithm
I have known it since when I was in the primary school. However, I did not get its underlying insight until now, although it is simple. First, a brief description of the algorithm: Input, (a,b) Outpu
Euclid算法
1、编写递归函数求两个正整数a和b的最大公约数(GCD,Greatest Common Divisor),使用Euclid算法:如果a除以b能整除,则最大公约数是b。否则,最大公约数等于b和a%b的最大公约数#includeint gcd(int a,int b){   if(a%b==0)  {if(b>0)     return b;    else    
求最大公因数的经典算法:Euclid辗转相除法
求两整数最大公约数比较常用,我们可以自定义函数gcd使用: int gcd(int a,int b) { int r; while(b&gt;0) { r=a%b;  a=b;  b=r;} return r;} 或用三目运算符简化: int gcd(int a,int b) {  b&gt;0?gcd(b,a%b):a)} 如编写程序输入一个分数然后将其化为最简形式,