55 lines
972 B
C++
55 lines
972 B
C++
|
//H - <20><><EFBFBD><EFBFBD>
|
|||
|
//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);//û<><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+<2B><><EFBFBD><EFBFBD>m,n<><6E><EFBFBD><EFBFBD>
|
|||
|
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 <20><><EFBFBD><EFBFBD> e=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>
|
|||
|
printf("Scenario #%d:\n%d %d %.1lf\n\n",m-t,i,e,s);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Presentation Error
|
|||
|
}
|
|||
|
return 0;
|
|||
|
}
|