UVA - 12301-An Angular Puzzle
2014-09-12 19:34
239 查看
给出如图三角形里的五个角度,求出x
我的做法:
直接写出表达式解
我的代码:
#include<iostream>
#include<map>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
const double pi=acos(-1.0);
struct dot
{
double x,y;
dot(){}
dot(double a,double b){x=a,y=b;}
friend dot operator -(dot a,dot b){return dot(a.x-b.x,a.y-b.y);}
friend double operator /(dot a,dot b){return a.x*b.x+a.y*b.y;}
};
double dis(dot a,dot b)
{
return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}
double cang(dot a,dot b)
{
return acos(a/b/dis(a,dot(0,0))/dis(b,dot(0,0)));
}
double cg1(double a)
{
return a/pi*180;
}
double cg2(double a)
{
return a/180*pi;
}
int main()
{
dot f,g;
double a,b,c,d,e,k[10],ans;
while(cin>>a>>b>>c>>d>>e)
{
if(a+b+c+d+e==0)
break;
if(a+b+c+d+e>180.0)
printf("Impossible\n");
else
{
a=cg2(a);b=cg2(b);c=cg2(c);d=cg2(d);e=cg2(e);
k[1]=-tan(d+e);
k[2]=tan(c);
k[3]=tan(b+c);
k[4]=-tan(e);
f.x=k[1]/(k[1]-k[2]);
f.y=k[2]*f.x;
g.x=k[4]/(k[4]-k[3]);
g.y=k[3]*g.x;
ans=cg1(cang(f-g,f));
printf("%.2lf\n",ans);
}
}
}
相关文章推荐
- uva 12301 - An Angular Puzzle(几何)
- An Angular Puzzle - UVa 12301 几何
- uva 12301 - An Angular Puzzle
- UVA 12301 - An Angular Puzzle(计算几何)
- How to debug an Angular 2 application with Chrome and VS Code
- Uva:156 - Ananagrams
- uva 1116 - Puzzle(贪心)
- UVa 11129 - An antiarithmetic permutation
- Uva - 156 - Ananagrams
- 【angular】you have to be inside an Angular CLI project in order to use the serve command
- UVa-227 - Puzzle
- UVA 156 Ananagrams 模拟+字符串处理
- Puzzle UVA - 227
- UVA156-5.4-Ananagrams-映射(map)
- UVA 11129 An antiarithmetic permutation 非等差数列 贪心 递归
- [Angular 2] Order Dynamic Components Inside an Angular 2 ViewContainer
- 假期训练——Puzzle UVA - 227 模拟+DFS and similar
- Ananagrams UVA - 156
- 紫书章三习题5——UVA 227 Puzzle
- UVA227 Puzzle (字符串题)