1043 - Triangle Partitioning
You are given AB, AC and BC. DE is parallel to BC. You are also given the area ratio between ADE and BDEC. You have to find the value of AD.See the picture below.
Input
Input starts with an integer T (≤ 25), denoting the number of test cases.
Each case begins with four real numbers denoting AB, AC, BC and the ratio of ADE and BDEC (ADE / BDEC). You can safely assume that the given triangle is a valid triangle with positive area.
Output
For each case of input you have to print the case number and AD. Errors less than 10-6 will be ignored.
Sample Input |
Output for Sample Input |
4100 100 100 210 12 14 17 8 9 10
8.134 9.098 7.123 5.10 |
Case 1: 81.6496580Case 2: 7.07106781Case 3: 6.6742381247Case 4: 7.437454786 |
题目类型:简单二分
算法分析:可以直接的手算出计算的公式计算AD长
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
#include <iostream> #include <fstream> #include <iomanip> #include <cmath> using namespace std; int main() { // ifstream cin ("aaa.txt"); int cases, flag = 1; cin >> cases; double ab, ac, bc, rad; while (cases--) { cin >> ab >> ac >> bc >> rad; cout << "Case " << flag++ << ": " << fixed << setprecision (6) << ab * sqrt (rad / (rad + 1)) << endl; } return 0; } |
- « 上一篇:lightoj1042
- lightoj1045:下一篇 »