Pagini recente » Cod sursa (job #1144970) | Cod sursa (job #2593392) | Cod sursa (job #2985430) | Cod sursa (job #1333402) | Cod sursa (job #2360232)
#include <bits/stdc++.h>
using namespace std;
ifstream f("rubarba.in");
ofstream g("rubarba.out");
typedef long double ld;
int i,n;
ld x,y,t1x,t2x,t1y,t2y,mij,st,dr=2*atan(1),s,c;
pair<int,int> v[100002];
ld rotim(ld u)
{
t1x=t1y=1e9;
t2x=t2y=-1e9;
for(int i=1;i<=n;++i)
{
s=sin(u);
c=cos(u);
x=v[i].first*c-v[i].second*s;
y=v[i].first*s+v[i].second*c;
t1x=min(t1x,x);
t2x=max(t2x,x);
t1y=min(t1y,y);
t2y=max(t2y,y);
}
return (t2x-t1x)*(t2y-t1y);
}
int main()
{
ios::sync_with_stdio(false);
f>>n;
for(int i=1;i<=n;++i) f>>v[i].first>>v[i].second;
while(dr-st>1e-17)
{
mij=(st+dr)/2.0;
if(rotim(mij+1e-17)<rotim(mij)) st=mij;
else dr=mij;
}
g<<fixed<<setprecision(2)<<rotim(st);
return 0;
}