55 lines
972 B
C++
55 lines
972 B
C++
//H - 面积
|
||
//https://vjudge.net/contest/508277#problem/H
|
||
#include<iostream>
|
||
#include<cstdio>
|
||
#include<cmath>
|
||
#include<algorithm>
|
||
#include<cstring>
|
||
using namespace std;
|
||
const int N=101;
|
||
double s;
|
||
int n,i,j,tmp,e,m,t;
|
||
struct dot
|
||
{
|
||
int x,y;//int->double
|
||
} a[N];
|
||
double cross(double x1,double y1,double x2,double y2)
|
||
{
|
||
// printf("(%d,%d)(%d,%d):%d\n",x1,y1,x2,y2,x1*y2-x2*y1) ;
|
||
return x1*y2-x2*y1;
|
||
}
|
||
int gcd(int a,int b)
|
||
{
|
||
if(a<b) swap(a,b);//0~
|
||
while(b!=0)
|
||
{
|
||
tmp=a%b;
|
||
a=b;
|
||
b=tmp;
|
||
}
|
||
return a;
|
||
}
|
||
int main()
|
||
{
|
||
scanf("%d",&t);
|
||
m=t;
|
||
while(t--)
|
||
{
|
||
s=0,e=0;
|
||
scanf("%d",&n);//没有输入+吗,m,n搞混
|
||
memset(a,0,sizeof(dot)*(n+1));
|
||
for(i=1; i<=n; i++)
|
||
{
|
||
scanf("%d%d",&a[i].x,&a[i].y);
|
||
j=i-1;
|
||
e+=gcd(abs(a[i].x),abs(a[i].y));
|
||
a[i].x+=a[j].x;
|
||
a[i].y+=a[j].y;
|
||
s+=cross(a[j].x,a[j].y,a[i].x,a[i].y)/2;
|
||
}
|
||
i=s+1-e/2.0;//Pick 定理 e=边上整个的点
|
||
printf("Scenario #%d:\n%d %d %.1lf\n\n",m-t,i,e,s);//两个空行Presentation Error
|
||
}
|
||
return 0;
|
||
}
|