poj 2354 Titanic
来源:互联网 发布:二手手机回收评估软件 编辑:程序博客网 时间:2024/04/27 19:35
题目:泰坦尼克(⊙v⊙);通过无线电测量冰山的位置,给出船和冰山的精度纬度,求距离。
分析:计算几何、大地坐标系。利用公式计算即可;圆心角:acos(cos(la1)*cos(la2)*cos(lo1-lo2)+sin(la1)*sin(la2)。
注意:1.输入格式好恶心;2.用c++救AC了g++无限WA。。。
#include <iostream>#include <cstdlib>#include <cstdio>#include <cmath>using namespace std;double dist( double l1, double d1, double l2, double d2 ){double r = 6875.0/2;double p = acos(-1.0);l1 *= p/180;d1 *= p/180;l2 *= p/180;d2 *= p/180;return r*acos(cos(l1)*cos(l2)*cos(d1-d2)+sin(l1)*sin(l2));}int main(){char temp[100];double d,m,s,l1,l2,d1,d2,dis;for ( int i = 0 ; i < 9 ; ++ i ) scanf("%s",temp);scanf("%lf^%lf'%lf\" %s",&d,&m,&s,temp);l1 = d+m/60+s/3600;if ( temp[0] == 'S' ) l1 *= -1;scanf("%s",temp);scanf("%lf^%lf'%lf\" %s.",&d,&m,&s,temp);d1 = d+m/60+s/3600;if ( temp[0] == 'W' ) d1 *= -1;for ( int i = 0 ; i < 5 ; ++ i ) scanf("%s",temp);scanf("%lf^%lf'%lf\" %s",&d,&m,&s,temp);l2 = d+m/60+s/3600;if ( temp[0] == 'S' ) l2 *= -1;scanf("%s",temp);scanf("%lf^%lf'%lf\" %s.",&d,&m,&s,temp);d2 = d+m/60+s/3600;if ( temp[0] == 'W' ) d2 *= -1;scanf("%s",temp);dis = dist(l1,d1,l2,d2);printf("The distance to the iceberg: %.2lf miles.\n",dis);if ( floor(dis+0.005) < 100 ) printf("DANGER!\n");return 0;}
- POJ 2354 Titanic
- poj 2354 Titanic
- POJ 2354 Titanic
- poj 2354 || URAL 1030 Titanic
- poj 2354 Titanic(球面两点距离)
- poj 3407 Brookebond s'en va en guerre... && poj 2354 Titanic
- Titanic
- POJ2354-Titanic
- titanic prediction
- 【kaggle】Titanic
- Kaggle: Titanic
- kaggle:titanic
- titanic+tensorflow
- kaggle-Titanic
- the lose of Titanic
- 重看《Titanic》
- Ural 1030. Titanic
- Titanic : ML from Disaster
- VB.Net水晶报表:基本调用模块例子
- 如何把开发者变成创始人?
- TQ210裸机编程(8)——PWM
- 解决hash冲突
- 身高预测
- poj 2354 Titanic
- 黑马程序员----枚举类型的作用及类型转换(学习总结)
- github添加SSH keys
- 清除系统垃圾win7.bat【在前人基础上修改而成】
- 全局变量、局部变量、静态全局变量、静态局部变量的区别
- 最大的最大公约数-数论
- JAVA中CLASS.FORNAME的含义
- Lucene.Net多字段查询
- 最大子序列、最长递增子序列、最长公共子串、最长公共子序列、字符串编辑距离