- 博客(0)
- 资源 (2)
空空如也
凸包面积的计算~~~~
stack<point> s;
cin>>n;
for(i = 0; i < n; i++)
cin>>pot[i].x>>pot[i].y;
x = pot[0].x;
y = pot[0].y;
p = 0;
for(i = 1; i < n; i++) //寻找最左上的点
{
if(pot[i].y < y || (pot[i].y == y && pot[i].x < x))
{
x = pot[i].x;
y = pot[i].y;
p = i;
}
}
p0.x = x;
p0.y = y;
swap(pot[0], pot[p]);
sort(pot + 1, pot + n, cmp); //排序
s.push(p0);
s.push(pot[1]);
s.push(pot[2]);
point t;
for(i = 3; i < n; i++) //凸包
{
while(!s.empty())
{
t = s.top();
s.pop();
p = ( pot[i].x-s.top().x)*(t.y-s.top().y) - (t.x-s.top().x)*(pot[i].y-s.top().y );
if(p < 0)
{
s.push(t);
break;
}
}
s.push(pot[i]);
}
double area = 0;
t = s.top();
s.pop();
area += (p0.x * t.y - p0.y * t.x)/2.0;
while(!s.empty())
{
area += (t.x * s.top().y - t.y * s.top().x)/2.0;
t = s.top();
s.pop();
}
if(area < 0)
area = -area;
cout<<fixed<<setprecision(3)<<area<<endl;
2010-05-18
大整数的乘法----
while(k<=2*l)
{
temp=0;
s[k]=0;
for(i=0;i<=l;i++)
{
for(j=0;j<=l;j++)
{
if((i+j)==k-1)
{
temp+=(m[l-i]-48)*(n[l-j]-48);
}
}
}
v=(temp+t)%10;
s[k]=v;
t=(temp+t)/10;
k++;
}
temp=0;
for(i=0;i<=l;i++)
{
for(j=0;j<=l;j++)
if((i+j)==k-1)
{
temp+=(m[l-i]-48)*(n[l-j]-48);
}
}
temp+=t;
2010-05-18
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人