Pagini recente » Cod sursa (job #1907270) | Cod sursa (job #1605450) | Cod sursa (job #380402) | Cod sursa (job #2512222) | Cod sursa (job #2294500)
//ALEX ENACHE
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <time.h>
#include <iomanip>
#include <deque>
#include <math.h>
#include <cmath>
#include <assert.h>
#include <stack>
#include <bitset>
#include <random>
#include <chrono>
using namespace std;
//#include <iostream>
#include <fstream>
ifstream cin ("adapost2.in");ofstream cout ("adapost2.out");
struct nod{
double x , y;
};
nod v[50100];
double dirx[] = {0 , 0 , 1 , -1};
double diry[] = {1 , -1 , 0 , 0};
int n;
double dist (double x , double y){
double sum = 0;
for (int i=1; i<=n; i++){
sum += sqrt((x - v[i].x) * (x - v[i].x) + (y - v[i].y) * (y - v[i].y));
}
return sum;
}
int main() {
//freopen("input", "r", stdin);freopen("output", "w", stdout);
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n;
for (int i=1; i<=n; i++){
cin>>v[i].x>>v[i].y;
}
double x = 500;
double y = 500;
double p = 500;
double eps = 0.0001;
double MIN = 1e9;
while (p > eps){
int ok = 0;
for (int i=0; i<4; i++){
double X = x + dirx[i]*p;
double Y = y + diry[i]*p;
double d = dist(X , Y);
if (d < MIN){
MIN = d;
x = X;
y = Y;
ok = 1;
break;
}
}
if (!ok){
p /= 2.0;
}
}
cout<<setprecision(10)<<fixed<<x<<" "<<y<<'\n';
return 0;
}