⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1773.cpp

📁 哈尔滨工业大学ACM 竞赛网上在线试题集锦的源代码
💻 CPP
字号:
/*  This Code is Submitted by wywcgs for Problem 1773 on 2006-02-24 at 12:17:20 */ 
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

const int MAX = 1024;
const double INF = 1e10;

class Point {
private:
	double lat, lon;
public:
	double x, y, z;
	void make();
	double dis(const Point&) const;
	void print() const;
};
void Point::make() {
	scanf("%lf %lf", &lat, &lon);
	double i = lon * M_PI / 180, j = lat * M_PI / 180;
	double cosB = cos(j);
	x = cos(i) * cosB; y = sin(i) * cosB; z = sin(j);
}
double Point::dis(const Point& p) const {
	return sqrt((x-p.x)*(x-p.x)+(y-p.y)*(y-p.y)+(z-p.z)*(z-p.z));
}
void Point::print() const {
	printf("%.2lf %.2lf\n", lat, lon);
}

int main()
{
	int i, j, n;
	Point port[MAX];

	while(scanf("%d", &n) != EOF) {
		for(i = 0; i < n; i++) port[i].make();
		double dis = INF; int o;
		for(i = 0; i < n; i++) {
			double m = 0;
			for(j = 0; j < n; j++)
				if(i != j) m = max(m, port[i].dis(port[j]));
			if(m < dis) dis = m, o = i;
		}
		port[o].print();
	}

	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -