zoj 2105 Lifting the Stone

题意   裸的计算几何  求多边形重心;

#include<iostream>
#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std; double a,b,c,d,e,f;
double mix( double x,double y,double xx,double yy ){return x*yy - xx*y;}
int main( )
{
int N,T; scanf("%d",&T);
while( T-- )
{
scanf("%d",&N); scanf("%lf%lf%lf%lf",&a,&b,&c,&d);
double sumx = ,sumy = ,suma = ;
for( int i = ; i <= N; i++ )
{
scanf("%lf%lf",&e,&f);
double area = mix(e-a,f-b,c-a,d-b)/2.0;
sumx += (( a+c+e )*area);
sumy += (( b+d+f )*area);
suma += area;
c = e; d = f;
}
sumx = int(sumx/suma/3.0*100000.0);
sumy = int(sumy/suma/3.0*100000.0);
printf("%.2lf %.2lf\n",sumx/100000.0,sumy/100000.0);
}
return ;
}
上一篇:从零教你如何获取hadoop2.4源码并使用eclipse关联hadoop2.4源码


下一篇:salesforce lightning零基础学习(十三) 自定义Lookup组件(Single & Multiple)