Pagini recente » Cod sursa (job #301484) | Cod sursa (job #625830) | Cod sursa (job #1981789) | Cod sursa (job #472263) | Cod sursa (job #1824216)
#include<iostream>
#include<fstream>
#include<algorithm>
#include<set>
#include<climits>
#include<cstring>
#include<map>
#include<queue>
#include<vector>
#include<bitset>
#define mp make_pair
#define pb push_back
#define ff(i, x, n) for (int i = x; i <= n; ++i)
#define dd(i) cout << i <<'\n'
#define READ_FROM_FILE
using namespace std;
#ifdef READ_FROM_FILE
ifstream in("adapost2.in");
#define cin in
#endif
double x[50005], y[50005];
int n;
double dist(int x0, int y0);
int main(){
FILE *out = fopen("adapost2.out", "w");
double sx = 0, sy = 0, R = (1 << 30);
cin >> n;
ff(i, 1, n) {
cin >> x[i] >> y[i];
sx += x[i];
sy += y[i];
}
sx /= n;
sy /= n;
bool go;
double dd, d = 1000;
while (d >= 1e-8) {
do {
go = 0;
dd = dist(sx - d, sy);
if (R > dd) {
R = dd;
sx -= d;
go = 1;
}
dd = dist(sx, sy + d);
if (R > dd) {
R = dd;
sy += d;
go = 1;
}
dd = dist(sx + d, sy);
if (R > dd) {
R = dd;
sx += d;
go = 1;
}
dd = dist(sx, sy - d);
if (R > dd) {
R = dd;
sy -= d;
go = 1;
}
}while (0);
d /= 2.0;
}
fprintf(out, "%.6f %.6f\n", sx, sy);
//printf("%.5f %.5f\n", sx, sy);
}
double dist(int x0, int y0) {
double D = 0;
ff(i, 1, n) {
D += sqrt((x0 - x[i]) * (x0 - x[i]) + (y0 - y[i]) * (y0 - y[i]));
}
return D;
}