Pagini recente » Cod sursa (job #1646370) | Cod sursa (job #641906) | Cod sursa (job #2365991) | Cod sursa (job #2548325) | Cod sursa (job #1571529)
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
const double pi=3.142;
const double eps=1.e-15;
int n;
struct po
{
double x,y;
} ve[100005];
double johncena(double rot)
{
int i;
double si,co,xmi,ymi,xma,yma,xn,yn;
si=sin(rot);
co=cos(rot);
xn=co*ve[1].x-si*ve[1].y;
yn=si*ve[1].x+co*ve[1].y;
xmi=xma=xn;
ymi=yma=yn;
for(i=1; i<=n; i++)
{
xn=co*ve[i].x-si*ve[i].y;
yn=si*ve[i].x+co*ve[i].y;
if(xn-xmi<eps)
xmi=xn;
if(yn-ymi<eps)
ymi=yn;
if(xn-xma>=eps)
xma=xn;
if(yn-yma>=eps)
yma=yn;
}
return (xma-xmi)*(yma-ymi);
}
int main()
{
freopen("rubarba.in","r",stdin);
freopen("rubarba.out","w",stdout);
int i,j;
double st,dr,t1,t2;
scanf("%d",&n);
for(i=1; i<=n; i++)
scanf("%lf%lf",&ve[i].x,&ve[i].y);
st=0;
dr=pi*0.5;
while(dr-st>=eps)
{
t1=st+(dr-st)/3.0;
t2=st+((dr-st)/3.0)*2.0;
if(johncena(t1)<johncena(t2))
dr=t2;
else
st=t1;
}
printf("%.3lf\n",johncena(st));
return 0;
}