http://acm.hdu.edu.cn/vcontest/vtl/problem/showproblem/vtlid/1816/problemid/1005
![ContractedBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
#include
"
iostream
"
using namespace std;
int main()
{
int t;
int n,i;
int x[ 101 ],y[ 101 ];
cin >> t;
while (t -- )
{
double sum = 0 ;
cin >> n;
for (i = 0 ;i < n;i ++ ) cin >> x[i] >> y[i];
for (i = 1 ;i < n;i ++ )
{
sum += x[i] * y[i - 1 ] - x[i - 1 ] * y[i];
}
sum += y[n - 1 ] * x[ 0 ] - x[n - 1 ] * y[ 0 ];
if (sum < 0 ) sum =- sum;
printf( " %.1lf\n " ,sum * 0.5 );
}
return 0 ;
}
using namespace std;
int main()
{
int t;
int n,i;
int x[ 101 ],y[ 101 ];
cin >> t;
while (t -- )
{
double sum = 0 ;
cin >> n;
for (i = 0 ;i < n;i ++ ) cin >> x[i] >> y[i];
for (i = 1 ;i < n;i ++ )
{
sum += x[i] * y[i - 1 ] - x[i - 1 ] * y[i];
}
sum += y[n - 1 ] * x[ 0 ] - x[n - 1 ] * y[ 0 ];
if (sum < 0 ) sum =- sum;
printf( " %.1lf\n " ,sum * 0.5 );
}
return 0 ;
}