POJ 1654 Area(水题)

时间:2023-03-09 08:05:15
POJ 1654 Area(水题)

题目链接

卡了一下精度和内存。

 #include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
#define eps 1e-8
#define N 1000001
#define LL __int64
int a[] = {-,,,-,,,-,,};
int b[] = {-,-,-,,,,,,};
char str[N];
LL cross(LL x1,LL y1,LL x2,LL y2)
{
return x1*y2 - x2*y1;
}
int main()
{
int t,len,i;
LL x,y,ans,px,py;
scanf("%d",&t);
while(t--)
{
scanf("%s",str);
len = strlen(str);
px = ;
py = ;
ans = ;
for(i = ;i < len;i ++)
{
if(str[i] == '')break;
x = px+a[str[i]-''-];
y = py+b[str[i]-''-];
ans += cross(x,y,px,py);
px = x;
py = y;
}
ans += cross(px,py,,);
if(ans < ) ans = -ans;
if(ans% == )
printf("%I64d\n",ans/);
else
printf("%I64d.5\n",ans/);
}
return ;
}