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 ;}