题目大意:
两题几何水题。
1.UVA 11646 - Athletics Track
如图,体育场的跑道一圈400米,其中弯道是两段半径相同的圆弧,已知矩形的长宽比例为a:b,求长和宽的具体数值。
2.UVA 11817 - Tunnelling the Earth
给出地球上起点和终点(均用度数的经纬度表示),从起点出发,可以沿着球面最短路径走。也可以钻隧道,走直线。求这两种方法的路程差。
题解:
1、UVA 11646 - Athletics Track
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2693
直接推到一下公式,我是画个对角线,求个角度。。。。挺简单的。
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
double a,b;
int kase=1;
char temp[5];
while(~scanf("%lf%s%lf",&a,temp,&b))
{
double g=atan2(b,a);
double r=b/2/sin(g);
double k=400/(2*a+4*g*r);
printf("Case %d: ",kase++);
printf("%.10lf %.10lf\n",k*a,k*b);
}
return 0;
}
2.UVA 11817 - Tunnelling the Earth
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2917
题目给出的是度数,要先化成弧度。
然后,求出坐标即可。
吐槽:百度了下经纬度。。。。然后已知经纬度求坐标好像高数里面的三重积分的球面坐标- -|||
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const double r=6371009;
const double pi=acos(-1.0);
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
double a,b;
double x1,y1,z1,x2,y2,z2;
scanf("%lf%lf",&a,&b);
a=a*pi/180;
b=b*pi/180;//把经度纬度换算成弧度
x1=r*cos(a)*cos(b);
y1=r*cos(a)*sin(b);
z1=r*sin(a);
scanf("%lf%lf",&a,&b);
a=a*pi/180;
b=b*pi/180;
x2=r*cos(a)*cos(b);
y2=r*cos(a)*sin(b);
z2=r*sin(a);
double len1=sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) +(z1-z2)*(z1-z2));
double angle=2*asin(len1/2/r);
double len2=angle*r;
printf("%.0lf\n",len2-len1);
}
return 0;
}