Ran Mouri and Sonoko Suzuki are preparing for the final exams. They decided to study mathematics as it is the hardest subject for them. While they are solving mathematical problems, they faced troubles with some questions, including the following question:
You are given a drawing for a sensor and some measurements about it. You have to find the rest of measurements. Sensor's design is as follow:
The data you have is the length of , the length of
, the area of
oda, and the area of
obc. Your task is to calculate x and y, where x is the length of
and y is the length of
.
Can you help Ran and Sonoko Suzuki by solving this question?
Input
The first line contains an integer T (1 ≤ T ≤ 2 × 105), in which T is the number of test cases.
Then T lines follow, each line contains four integers k, l, m, and n (1 ≤ k, l, m, n ≤ 1012), in which k is the length of , l is the length of
, m is the area of
oda, and n is the area of
obc.
Output
For each test case, print a single line containing two numbers x and y, where x is the length of and y is the length of
. Your output will be considered correct if the absolute or relative error of every number in your output does not exceed 10 - 6.
Example
Input
1 18 16 72 288
Output
20 14
因为 圆内四边形对角互补 易证:三角形oda 相似 三角形obc
则:k /( x + l) = sqrt(m / n);
k / (k + y) = sqrt(m / n);
求出x,y 即可
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cmath>
#include<vector>
using namespace std;
int main(){
int t;
scanf("%d", &t);
while(t--){
double k, l, m, n;
double x, y;
cin >> k >> l >> m >> n;
printf("%.7lf %.7lf\n", k / (sqrt(m / n)) - l, l / sqrt(m / n) - k);
}
return 0;
}
以右图所示圆内接四边形ABCD为例,圆心为O,延长AB至E,AC、BD交于P,则:
▶圆内接四边形的对角互补:∠BAD+∠DCB=180°,∠ABC+∠ADC=180°
▶圆内接四边形的任意一个外角等于它的内对角:∠CBE=∠ADC
▶圆心角的度数等于所对弧的圆周角的度数的两倍:∠AOB=2∠ACB=2∠ADB [1]
▶圆内接四边形对应三角形相似:△ABP∽△DCP(三个内角对应相等)
▶相交弦定理:AP×CP=BP×DP
▶托勒密定理:AB×CD+AD×CB=AC×BD