Pagini recente » Cod sursa (job #3191184) | Cod sursa (job #1726076) | Cod sursa (job #2933445) | Cod sursa (job #174037) | Cod sursa (job #2080043)
/**
* Worg
*/
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#define x first
#define y second
FILE *fin = freopen("rubarba.in", "r", stdin); FILE *fout = freopen("rubarba.out", "w", stdout);
const double eps = 5e-14;
const double pi = std::acos(-1.0);
const double maxC = 1e12;
/*--------- Data --------*/
int N;
std::vector<std::pair<double, double > > points;
/*--------- --------*/
double Compute(double alfa) {
double sin = std::sin(alfa), cos = std::cos(alfa);
double maxX = -maxC, maxY = -maxC, minX = maxC, minY = maxC;
for(auto& p : points) {
double x = p.x * cos - p.y * sin;
double y = p.x * sin + p.y * cos;
minX = std::min(minX, x);
maxX = std::max(maxX, x);
minY = std::min(minY, y);
maxY = std::max(maxY, y);
}
return (maxY - minY) * (maxX - minX);
}
int main() {
scanf("%d", &N);
for(int i = 0; i < N; i++) {
double a, b; scanf("%lf%lf", &a, &b);
points.emplace_back(a, b);
}
//printf("%.15f\n", pi);
double left = 0, right = pi / 2, mid;
while(right - left >= eps) {
mid = left + (right - left) / 2;
if(Compute(mid) >= Compute(mid + eps)) {
left = mid;
} else {
right = mid;
}
}
printf("%.6f", Compute(mid));
return 0;
}