Codeforces Gym-101116-F (Flight Plan)
来源:互联网 发布:爱知流量计 手机 编辑:程序博客网 时间:2024/05/20 15:59
题目链接:
题目大意:
数据范围:
解题思路:
//化为弧度制double rad(double d) { return d * PI / 180.0;}//求两点之间的距离double dis(Point A, Point B) { A.x = rad(A.x); A.y = rad(A.y); B.x = rad(B.x); B.y = rad(B.y); double ang = acos(cos(A.x) * cos(B.x) * cos(A.y - B.y) + sin(A.x) * sin(B.x)); double s = ang * R; //R为地球半径 return s;}
double dis(Point A, Point B) { double Theta = A.x - B.x; double Beta = A.y - B.y; double ang = 2 * asin(sqrt(sin(Theta / 2) * sin(Theta / 2) + cos(A.x) * cos(B.x) * sin(Beta / 2) * sin(Beta / 2))); double s = ang * R; return s;}
#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>#include <queue>#include <set>#include <iostream>using namespace std;typedef long long LL;const int inf = 1 << 30;const LL INF = 1LL << 60;const double PI = acos(-1.0);const double R = 6371.0;int T;struct Point { double x, y;};Point a, b, c;//化为弧度制double rad(double d) { return d * PI / 180.0;}//求弧长double arc(double Theta, double r) { return Theta * r;}//求两点之间的距离double dis(Point A, Point B) { A.x = rad(A.x); A.y = rad(A.y); B.x = rad(B.x); B.y = rad(B.y); double ang = acos(cos(A.x) * cos(B.x) * cos(A.y - B.y) + sin(A.x) * sin(B.x)); /*这个公式也可以,但我不知道是怎么推的 double Theta = A.x - B.x; double Beta = A.y - B.y; double ang = 2 * asin(sqrt(sin(Theta / 2) * sin(Theta / 2) + cos(A.x) * cos(B.x) * sin(Beta / 2) * sin(Beta / 2))); */ double s = ang * R; return s;}int main(){ scanf("%d", &T); while(T--) { scanf("%lf %lf %lf %lf", &a.x, &a.y, &b.x, &b.y); //这个稍微想想就明白了,一个小坑点 if(abs(a.y - b.y) > 180.0) { if(a.y < 0.0) a.y += 360.0; else if(b.y < 0.0) b.y += 360.0; } c.x = a.x; c.y = b.y; double r = R * cos(rad(a.x)); printf("%.10lf %.10lf\n", dis(a, b), dis(b, c) + arc(rad(abs(a.y - b.y)), r)); } return 0;}
阅读全文
0 0
- Codeforces Gym-101116-F (Flight Plan)
- codeforces Gym 101102F
- Codeforces-GYM-100726F
- Codeforces GYM 100803F
- 【Codeforces Gym 100187F 】+ 贪心
- codeforces-gym-100187-F【贪心】
- Codeforces gym 101350F 想法
- Codeforces Gym 101142 F. Folding
- Codeforces Gym 101164 F. Letter
- codeforces gym 100342F Move to Front
- codeforces gym 101142 F(思维)
- Codeforces Gym 100642 C D F
- Codeforces Gym 100623F Problem F. Fenwick Tree
- Codeforces Gym 100342F Move to Front 平衡树
- Codeforces Gym 100548F Color (组合数+容斥)
- Codeforces Gym 100589F Count Ways(DP+组合数学)
- Codeforces Gym 100825F Transportation Delegation (最大流)
- CodeForces Gym 100989F Mission in Amman (A)
- iOS UI事件传递与响应者链
- ROS--urdf在rviz之中的显示(补充)
- built-in function 错误的解决
- 初学python遇到的问题大全
- MacOS连接树莓派3(Raspberry Pi 3)
- Codeforces Gym-101116-F (Flight Plan)
- Android Studio Warning警告系列
- test
- 存储器
- JavaWeb学习(一)
- (String)java中字符串的比较
- JAVA枚举类的基本使用
- hud-1874-畅通工程续(floyd)最短路入门
- RocketMQ源码解析-Producer消息发送