?? 1773.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 + -