#include #include #include using namespace std; const double eps=1e-10; const double PI=acos(-1); int dcmp(double x) { return (x>eps)-(x<-eps); } struct Point3 { double x,y,z; Point3(double x=0,double y=0,double z=0):x(x),y(y),z(z) {} }; typedef Point3 Vector3; Vector3 operator+(Point3 A,Point3 B) { return Point3(A.x+B.x,A.y+B.y,A.z+B.z); } Vector3 operator-(Point3 A,Point3 B) { return Point3(A.x-B.x,A.y-B.y,A.z-B.z); } Vector3 operator*(Point3 A,double p) { return Point3(A.x*p,A.y*p,A.z*p); } Vector3 operator/(Point3 A,double p) { return Point3(A.x/p,A.y/p,A.z/p); } bool operator<(Point3 &A,Point3 &B) { return A.x=p-a) return b; else return a; } int main() { int T; cin>>T; double a1,b1,a2,b2; double R=6371009; double x1,y1,z1,x2,y2,z2; while(T--) { cin>>b1>>a1>>b2>>a2; b1=b1/180.0*PI; a1=a1/180.0*PI; b2=b2/180.0*PI; a2=a2/180.0*PI; x1=R*cos(b1)*cos(a1); y1=R*cos(b1)*sin(a1); z1=R*sin(b1); x2=R*cos(b2)*cos(a2); y2=R*cos(b2)*sin(a2); z2=R*sin(b2); Point3 A=Point3(x1,y1,z1); Point3 B=Point3(x2,y2,z2); double real_dist=Length(A-B); Point3 P; double arc_dist=Angle(A-P, B-P)*R; printf("%.0lf\n",arc_dist-real_dist); } }