An Angular Puzzle - UVa 12301 几何
2015-02-05 16:08
441 查看
An Angular Puzzle
Here is an old interesting puzzle: In the picture below, what is the angle of DEA, in degrees? Note that 5 angles are already given. The picture is drawn to scale.You're to solve a generalized problem: let a, b, c, d, e be the angle of ACB, CAE, EAB, CBD, DBA (in degrees), what is the angle of DEA, in degrees?
Note that E must be strictly on segment BC (cannot coincide with B or C), and D must be strictly on segment AC (cannot coincide with A or C). The triangle ABC must be non-degenerated (i.e. ABC cannot be collinear).
Not all combination of parameters a, b, c, d and e corresponds to a valid figure described above. Your program should be able to detect this.
Input
There will be at most 100 test cases. Each case contains 5 integers a, b, c, d, e (0 < a, b, c, d, e < 90). The last test case is followed by five zeros, which should not be processed.Output
For each test case, print the answer to two decimal places. If there is more than one solution, print "Multiple solutions". If the input is incorrect (i.e. there is no valid picture for these parameters), print"Impossible" (without quotes).
Sample Input
20 10 70 20 60 30 5 70 15 60 60 30 30 30 30 30 40 40 40 40 0 0 0 0 0
Output for the Sample Input
20.00 12.96 30.00 Impossible
题意:求图中角x的大小。
思路:假设AB=1,那么可以求出AD,AE的长度,进而可以求出DE的长度,然后x的大小就可以求出。
AC代码如下:
#include<cstdio> #include<cstring> #include<cmath> using namespace std; int main() { int a,b,c,d,e,f; double AB,AE,AD,p,DE,ans; while(~scanf("%d%d%d%d%d",&a,&b,&c,&d,&e) && a+b+c+d+e>0) { if(a+b+c+d+e!=180) { printf("Impossible\n"); continue; } AB=1; AE=AB*sin((d+e)*M_PI/180)/sin((180-c-d-e)*M_PI/180); AD=AB*sin(e*M_PI/180)/sin((180-b-c-e)*M_PI/180); DE=sqrt(AE*AE+AD*AD-2*AE*AD*cos(b*M_PI/180)); ans=acos((AE*AE+DE*DE-AD*AD)/(2*AE*DE))/M_PI*180; printf("%.2f\n",ans); } }
相关文章推荐
- UVA 12301 - An Angular Puzzle(计算几何)
- uva 12301 - An Angular Puzzle(几何)
- uva 12301 - An Angular Puzzle
- UVA - 12301-An Angular Puzzle
- 计算几何专项:UVa 12301
- UVA - 12301 - An Angular Puzzle (计算几何~平面三角)
- uva 10321 - Polygon Intersection(几何)
- uva 1463 - Largest Empty Circle on a Segment(二分+三分+几何)
- 反片语(Ananagrams,Uva 156)
- uva 11129 An antiarithmetic permutation
- UVa 156 Ananagrams
- Puzzle,ACM/ICPC World Finals 1993, UVa227
- uva227 - Puzzle
- UVa 11178计算几何 模板题
- 计算几何专项:UVa 10585
- 【HDU 5572 An Easy Physics Problem】计算几何基础
- [AngularJS] Angular 1.3 Anuglar hint
- 计算几何 - UVA - 12304(附2D计算几何模板)
- UVALive 7749 Convex Contour (计算几何)
- UVa 227, Puzzle