Ultraviolet A 11817-tunnelling the earth

Source: Internet
Author: User

From one point on the earth to another, calculate the difference between the sphere distance between two points and the linear distance. Assume that the Earth is a positive sphere with a radius of 6371009.

# Include <iostream> # include <cmath> # define R 6371009 # define Pi 2.0 * asin (1.0) using namespace STD; double Ang (double lt1, double lt2, double lg1, double lg2) {return ACOs (COS (lt1) * Cos (lt2) * Cos (lg1-lg2) + sin (lt1) * sin (lt2);} double dis_line (double lt1, double lt2, double lg1, double lg2) {return r * SQRT (2-2 * (COS (lt1) * Cos (lt2) * Cos (lg1-lg2) + sin (lt1) * sin (lt2);} double dis_sphere (double lt1, double lt2, double lg1, double lg2) {return r * Ang (lt1, lt2, lg1, lg2 );} int main () {int t; double lt1, lt2, lg1, lg2; CIN> T; while (t --) {CIN> lt1> lg1> lt2> lg2; lt1 * = PI/180.0; lt2 * = PI/180.0; lg1 * = PI/180.0; lg2 * = PI/180.0; long l = 0.5 + dis_sphere (lt1, lt2, lg1, lg2)-dis_line (lt1, lt2, lg1, lg2 ); cout <L <Endl;} return 0 ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.