Pagini recente » Cod sursa (job #3137218) | Cod sursa (job #3127714) | Cod sursa (job #1276743) | Monitorul de evaluare | Cod sursa (job #2068009)
#include <fstream>
#include <cmath>
#include <iomanip>
#define pi 3.14159265
#define DIM 100002
using namespace std;
ifstream f("rubarba.in");
ofstream g("rubarba.out");
int n;
const double INF = 1e12;
double minim = INF;
const double eps = 4e-15;
double convert(double unghi){
return (unghi / 180.0) * pi;
}
struct punct{
double x, y;
}pct[DIM];
double calc(double unghi){
//unghi = convert(unghi);
double xmax = -INF, xmin = INF, ymax = -INF, ymin = INF;
for(int i = 1; i <= n; ++ i){
double x = pct[i].x * cos(unghi) - pct[i].y * sin(unghi);
double y = pct[i].x * sin(unghi) + pct[i].y * cos(unghi);
xmax = max(x, xmax);
xmin = min(x, xmin);
ymax = max(y, ymax);
ymin = min(y, ymin);
}
return (xmax - xmin) * (ymax - ymin);
}
int main()
{
f>>n;
for(int i = 1; i <= n; ++ i)
f>>pct[i].y>>pct[i].x;
double st = 0, dr = M_PI / 2;
double mid;
while(dr - st >= eps){
mid = st + (dr - st) / 2;
if(calc(mid) >= calc(mid + eps))
st = mid;
else
dr = mid;
}
g<<setprecision(2)<<fixed<<calc(mid);
return 0;
}