uva 12301 - An Angular Puzzle
2013-08-20 22:17
176 查看
题意:如图,已知角ACB,
角CAE,
角EAB, 角CBD, 角DBA (in degrees), 求角 DEA。
注意:在 Output 中,“If there is more than one solution, print "Multiple
solutions"”这句话是迷惑你的,根本没有这种情况!
#include<iostream>
#include<iomanip>
#include<cmath>
#define pi (2.0*asin(1.0))
using namespace std;
typedef struct point
{
double x,y;
point(double xx=0,double yy=0):x(xx),y(yy){}
}vector;
vector operator - (point a,point b)
{
return vector(a.x-b.x,a.y-b.y);
}
point operator + (point a,vector b)
{
return point(a.x+b.x,a.y+b.y);
}
vector operator * (vector a,double b)
{
return vector(a.x*b,a.y*b);
}
double dot(vector a,vector b)
{
return a.x*b.x+a.y*b.y;
}
double len(vector a)
{
return sqrt(dot(a,a));
}
double angle(vector a,vector b)
{
return acos(dot(a,b)/len(a)/len(b));
}
double cross(vector a,vector b)
{
return a.x*b.y-a.y*b.x;
}
vector rot(vector a,double rad)
{
double c=cos(rad),s=sin(rad);
return vector(a.x*c-a.y*s,a.x*s+a.y*c);
}
point inter(point p,vector v,point q,vector w)
{
vector u=p-q;
double t=cross(w,u)/cross(v,w);
return p+v*t;
}
int main()
{
double a,b,c,d,e,s;
point pa,pb,pd,pe;
pb.x=10;
while(cin>>a>>b>>c>>d>>e)
{
s=a+b+c+d+e;
if(s==0) break;
else if(s!=180) cout<<"Impossible"<<endl;
else
{
b*=pi/180;
c*=pi/180;
d*=pi/180;
e*=pi/180;
vector v=rot(pb-pa,b+c),w=rot(pb-pa,pi-d-e);
pd=inter(pa,v,pb,rot(pb-pa,pi-e));
pe=inter(pa,rot(pb-pa,c),pb,w);
double x=angle(pe-pd,pe-pa)*180/pi;
cout<<fixed<<setprecision(2)<<x<<endl;
}
}
return 0;
}
角CAE,
角EAB, 角CBD, 角DBA (in degrees), 求角 DEA。
注意:在 Output 中,“If there is more than one solution, print "Multiple
solutions"”这句话是迷惑你的,根本没有这种情况!
#include<iostream>
#include<iomanip>
#include<cmath>
#define pi (2.0*asin(1.0))
using namespace std;
typedef struct point
{
double x,y;
point(double xx=0,double yy=0):x(xx),y(yy){}
}vector;
vector operator - (point a,point b)
{
return vector(a.x-b.x,a.y-b.y);
}
point operator + (point a,vector b)
{
return point(a.x+b.x,a.y+b.y);
}
vector operator * (vector a,double b)
{
return vector(a.x*b,a.y*b);
}
double dot(vector a,vector b)
{
return a.x*b.x+a.y*b.y;
}
double len(vector a)
{
return sqrt(dot(a,a));
}
double angle(vector a,vector b)
{
return acos(dot(a,b)/len(a)/len(b));
}
double cross(vector a,vector b)
{
return a.x*b.y-a.y*b.x;
}
vector rot(vector a,double rad)
{
double c=cos(rad),s=sin(rad);
return vector(a.x*c-a.y*s,a.x*s+a.y*c);
}
point inter(point p,vector v,point q,vector w)
{
vector u=p-q;
double t=cross(w,u)/cross(v,w);
return p+v*t;
}
int main()
{
double a,b,c,d,e,s;
point pa,pb,pd,pe;
pb.x=10;
while(cin>>a>>b>>c>>d>>e)
{
s=a+b+c+d+e;
if(s==0) break;
else if(s!=180) cout<<"Impossible"<<endl;
else
{
b*=pi/180;
c*=pi/180;
d*=pi/180;
e*=pi/180;
vector v=rot(pb-pa,b+c),w=rot(pb-pa,pi-d-e);
pd=inter(pa,v,pb,rot(pb-pa,pi-e));
pe=inter(pa,rot(pb-pa,c),pb,w);
double x=angle(pe-pd,pe-pa)*180/pi;
cout<<fixed<<setprecision(2)<<x<<endl;
}
}
return 0;
}
相关文章推荐
- UVA 12301 - An Angular Puzzle(计算几何)
- uva 12301 - An Angular Puzzle(几何)
- An Angular Puzzle - UVa 12301 几何
- UVA - 12301-An Angular Puzzle
- UVA 11129 - An antiarithmetic permutation
- [AngularJS] Angular 1.3 Anuglar hint
- UVA - 227 Puzzle
- UVA156-5.4-Ananagrams-映射(map)
- [Angular 2] Order Dynamic Components Inside an Angular 2 ViewContainer
- uva live 12846 A Daisy Puzzle Game
- uva 519 Puzzle (II)
- 假期训练——Puzzle UVA - 227 模拟+DFS and similar
- Ananagrams——Uva 156
- UVA - 519 Puzzle (II)(回溯+剪枝)
- UVa 156 - Ananagrams【各种stl】
- 紫书章三习题5——UVA 227 Puzzle
- (UVA)227 - Puzzle
- UVA 156 Ananagrams
- Ananagrams uva156
- trackr: An AngularJS app with a Java 8 backend – Part III