7月4日 Satellites

tlocdx / 2023-08-24 / 原文

Satellites

#include <iostream>
#include <cmath>
using namespace std;

int main() {
  const double pi = 3.14159265358979323846;
  const double earthR = 6440;
  double a = 0, s = 0;
  std::string str = "";
  while (std::cin >> s >> a >> str) {
		if(str == "min"){
			a = a / 60;
		}

    double r1, r2;
    double r = s + earthR;
		// 圆弧距离
    r1 = (pi * 2 * r) * (a / 360);

		// 直线距离
		r2 = 2 * r * sin((pi * a) / 360);
		if(a > 180)
			r1 = 2 * pi * r - r1;

    printf("%.6f %.6f\n", r1, r2);
  }
  return 0;
}