跳到正文

题解

UVA 10221 题解

_Gabriel_约 2 分钟
原文
文章信息与版本

文章信息

发布
2023年7月4日
收录
2025年12月12日
更新
2026年11月9日
篇幅
约 2 分钟
题目
UVA10221

版本

  1. v2当前
  2. v1

大意

给出圆的半径 ss 和 圆心角(夹角) aa,求出圆心角所对应的圆弧距离和直线弦距离。

思路

假设 rr 为圆的半径,圆心角的角度 angleangle(以度为单位),0≤angle≤1800 \le angle \le 180。

以度为单位:

  • 圆弧距离:arc=2πr×angle360×60arc=2 \pi r \times \dfrac{angle}{360 \times 60}

  • 直线弦距离:dis=r×sin⁡(angle×π2×180×60)×2dis=r \times \operatorname{sin}(\dfrac{angle \times \pi}{2 \times 180 \times 60}) \times 2

以分为单位:

  • 圆弧距离:arc=2πr×angle360arc=2 \pi r \times \dfrac{angle}{360}

  • 直线弦距离:dis=r×sin⁡(angle×π2×180×60)×2dis=r \times \operatorname{sin}(\dfrac{angle \times \pi}{2 \times 180 \times 60}) \times 2

代码

C++
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const double r = 6440; //地球半径

int main() {
	double s, a;//s:卫星与地球表面的距离,a:两颗卫星对地球中心的夹角
	string str;
	while (cin >> s >> a >> str) {
		if (str[0] == 'm') {
			a /= 60;//分转换为度
		}
		double angle = M_PI * a / 180;
		double arc = angle * (s + r);//圆弧距离
		double dis = 2 * (s + r) * sin(angle / 2);//直线弦距离
		if (a > 180) {//夹角大于180度
			arc = 2 * M_PI * (s + r) - arc;
		}
		cout << fixed << setprecision(6) << arc;
		cout << " ";
		cout << fixed << setprecision(6) << dis;
		cout << "\n";
	}
	return 0;
}
原文