UVa 10897 - Travelling Distance
来源:互联网 发布:数据库包括 编辑:程序博客网 时间:2024/05/16 07:08
题目:给你地球上两点的经度和纬度,计算球面最近距离。
分析:计算几何、大地坐标系。利用公式计算连点间距离,再转化成弧长即可。
d = r*sqrt(2-2*(cos(lat1)*cos(lat2)*cos(lon1-lon2)+sin(lat1)*sin(lat2))) (推导见11817)
弧长:s = 2*asin(d/(2*r))*r
#include <stdio.h>#include <stdlib.h>#include <math.h>int main(){double r = 6371.01;double p = acos(-1.0);int n;char ch;double a,b,c,A1,B1,A2,B2;while ( scanf("%d",&n) != EOF )while ( n -- ) {scanf("%lf%lf%lf %c",&a,&b,&c,&ch);A1 = a+b/60.0+c/3600.0;if ( ch == 'S' ) A1 *= -1;A1 *= p/180.0;scanf("%lf%lf%lf %c",&a,&b,&c,&ch);B1 = a+b/60.0+c/3600.0;if ( ch == 'W' ) B1 *= -1;B1 *= p/180.0;scanf("%lf%lf%lf %c",&a,&b,&c,&ch);A2 = a+b/60.0+c/3600.0;if ( ch == 'S' ) A2 *= -1;A2 *= p/180.0;scanf("%lf%lf%lf %c",&a,&b,&c,&ch);B2 = a+b/60.0+c/3600.0;if ( ch == 'W' ) B2 *= -1;B2 *= p/180.0;double d = r*sqrt(2-2*(cos(A1)*cos(A2)*cos(B1-B2)+sin(A1)*sin(A2)));printf("%.2lf\n",2*asin(d/(2*r))*r);}return 0;}
- UVA 10897 Travelling Distance
- UVa 10897 - Travelling Distance
- UVA 11796 Dog Distance
- UVa 10140- Prime Distance
- uva 10140 - Prime Distance
- uva 11796 - Dog Distance
- UVA 11796 - Dog Distance
- UVA 11796Dog Distance
- UVA 11796 Dog Distance
- UVA 11796 Dog Distance
- UVA 11796 - Dog Distance
- UVA 11796 Dog Distance .
- Dog Distance UVA
- The Hamming Distance Problem-uva
- UVA 11796 Dog Distance 几何
- UVA 10140 - Prime Distance(数论)
- uva 10140 - Prime Distance(数论)
- Dog Distance - UVa 11796 几何
- 关于 libxml/tree.h' file not found
- 将LCD屏幕倒过来显示(LCD翻转)
- mysql学习总结
- 修改ssh端口后无法连接ssh了?
- Eclipse 快捷键 【super~
- UVa 10897 - Travelling Distance
- linux schedule() 流程图
- mysql命令行参数
- stat *查看文件修改时间
- jsp 和 js 跳转
- 十道海量数据处理面试题与十个方法大总结
- 采样率转换
- 诸行无常 是生灭法 生灭灭已 寂灭为乐
- java遍历Map时remove删除元素