poj2354Titanic(两点的球面距离)
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 100000
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
const double r = /2.0;
char s[];
int dcmp(double x)
{
if(fabs(x)<eps) return ;
return x<?-:;
}
void solve(double x1,double y1,double x2,double y2)
{
double ans = r*acos(sin(x1)*sin(x2)+
cos(x1)*cos(x2)*cos(y1-y2)); printf("The distance to the iceberg: %.2lf miles.\n",ans);
if(dcmp(ans-+0.005)<)
puts("DANGER!");
}
int main()
{
double d1,d2,d3,d4;
int a,b,c,i;
char dir[];
for(i = ; i < ; i++)
scanf("%s",s);
scanf("%s",s);
sscanf(s,"%d^%d'%d''",&a,&b,&c);
//printf("%d %d %d\n",a,b,c);
d1 = a+b/60.0+c/3600.0;
scanf("%s",dir);
if(dir[]=='S')
d1=-d1;
scanf("%s",s); scanf("%s",s);
sscanf(s,"%d^%d'%d''",&a,&b,&c);
//printf("%d %d %d\n",a,b,c);
d2 = a+b/60.0+c/3600.0;
scanf("%s",dir);
if(dir[]=='W')
d2=-d2; for(i = ; i < ; i++) scanf("%s",s);
scanf("%s",s);
sscanf(s,"%d^%d'%d''",&a,&b,&c);
//printf("%d %d %d\n",a,b,c);
d3 = a+b/60.0+c/3600.0;
scanf("%s",dir);
if(dir[]=='S')
d3=-d3; scanf("%s",s); scanf("%s",s);
sscanf(s,"%d^%d'%d''",&a,&b,&c);
//printf("%d %d %d\n",a,b,c);
d4 = a+b/60.0+c/3600.0;
scanf("%s",dir);
if(dir[]=='W')
d4=-d4;
scanf("%s",s); solve(d1*pi/,d2*pi/,d3*pi/,d4*pi/);
return ;
}
poj2354Titanic(两点的球面距离)的更多相关文章
- UVA 11817 Tunnelling the Earth --球面距离公式
题意: 给出两点的经纬度,求两点的球面距离与直线距离之差. 解法: 我们先算出球面距离,然后可以根据球面距离算出直线距离. 球面距离公式: R*acos(sin(W1)*sin(W2)+cos(W1) ...
- uva 11817 - Tunnelling the Earth
题意:从地球上的一个点到另一个点,求两点的球面距离和直线距离之差.假定地球是正球体,半径为6371009米. #include<iostream> #include<cmath> ...
- ACM计算几何模板——圆和球
#include <iostream> #include <cmath> using namespace std; #define eps 1e-10 /********** ...
- 【百度地图API】如何根据摩卡托坐标进行POI查询,和计算两点距离
原文:[百度地图API]如何根据摩卡托坐标进行POI查询,和计算两点距离 摘要: 百度地图API有两种坐标系,一种是百度经纬度,一种是摩卡托坐标系.在本章你将学会: 1.如何相互转换这两种坐标: 2. ...
- php 计算两点地理坐标的距离
<?php /** * 计算两点地理坐标之间的距离 * @param Decimal $longitude1 起点经度 * @param Decimal $latitude1 起点纬度 * @p ...
- 用 Excel 测试“绘制两点间连线”的算法
最近在研究和制作数字示波器,其中涉及一个小算法:需要将 ADC 采样的数值在 TFT LCD 屏幕上面显示并且用“线”连接起来. ADC 按照时序对输入电压采样后,记录的是一个个的数值,如果显示的时候 ...
- sql server2008根据经纬度计算两点之间的距离
--通过经纬度计算两点之间的距离 create FUNCTION [dbo].[fnGetDistanceNew] --LatBegin 开始经度 --LngBegin 开始维度 --29.49029 ...
- HDU 2376 树形dp|树上任意两点距离和的平均值
原题:http://acm.hdu.edu.cn/showproblem.php?pid=2376 经典问题,求的是树上任意两点和的平均值. 这里我们不能枚举点,这样n^2的复杂度.我们可以枚举每一条 ...
- CodeForces 459A Pashmak and Garden(水~几何-给两点求两点组成正方形)
题目链接:http://codeforces.com/problemset/problem/459/A 题目大意: 给出两个点(在坐标轴中),求另外两个点从而构成一个正方形,该正方形与坐标轴平行. 如 ...
随机推荐
- js格式化日期 年月日
/** * 格式化日期 * @param value * @param row ...
- DZY Loves Chemistry 分类: CF 比赛 图论 2015-08-08 15:51 3人阅读 评论(0) 收藏
DZY Loves Chemistry time limit per test 1 second memory limit per test 256 megabytes input standard ...
- [Django_1_0]初次见面
Django 初次见面 文章将写安装和第一次使用时候的操作.文章是照着文档做的,但是以后的内容会有不一样. 安装 pip install django 我这里是使用python3的,也可以使用 pip ...
- c++中两种常量方法的比较
[c++]在C++中定义常量的两种方法的比较 常量是定以后,在程序运行中不能被改变的标识符.C++中定义常量可以用#define .const 这两种方法.例如: #define PRICE 10 ...
- 2016年11月17日 星期四 --出埃及记 Exodus 20:8
2016年11月17日 星期四 --出埃及记 Exodus 20:8 "Remember the Sabbath day by keeping it holy.当记念安息日,守为圣日.
- java-pfx文件转换成16进制内容
public static void main(String[] args) throws Exception { String path = "D://111.pfx"; Inp ...
- COGS502. 长路上的灯
502. 长路上的灯 ☆ 输入文件:light.in 输出文件:light.out 简单对比时间限制:1 s 内存限制:128 MB [题目描述] 在一条无限长的路上,有一排无限长的路 ...
- MVC 直接把数据库的数据输出到view(太神奇了)
@model IEnumerable<MvcApplication32.Models.UserInfo> 后台是集合类型了 ,传到前台是model了,用 IEnumerable<&g ...
- int转多进制
char buf[4]; int len=100; _itoa(len,buf_len,16);//16代表十六进制,可用其他进制
- Linux Shell脚本面试25问
Q:1 Shell脚本是什么.它是必需的吗? 答:一个Shell脚本是一个文本文件,包含一个或多个命令.作为系统管理员,我们经常需要使用多个命令来完成一项任务,我们可以添加这些所有命令在一个文本文件( ...