/*
叉乘求多边形面积
*/
#include <iostream>
#include <cmath>
#define MAXN 1000001
using namespace std;
struct point {
int x;
int y;
} p[MAXN];
__int64 area_polygon(int n)
{
__int64 sum = 0;
for (int i = 0; i < n; i++)
sum += p[(i+1)%n].y * p[i].x - p[(i+1)%n].x * p[i].y;
return sum;
}
int main()
{
int n, i, number;
char num[MAXN];
__int64 x, y, ans;
int go[10][2]={{ 0, 0},
{-1, -1},
{ 0, -1},
{ 1, -1},
{-1, 0},
{ 0, 0},
{ 1, 0},
{-1, 1},
{ 0, 1},
{ 1, 1}};
scanf("%d", &n);
getchar();
p[0].x = 0;
p[1].x = 0;
while (n--)
{
scanf("%s", &num);
if (num[0] == '5')
{
printf("0\n");
continue;
}
x = 0;
y = 0;
for (i = 1; num[i] != '5'; i++)
{
number = num[i] - '0';
x += go[number][0];
y += go[number][1];
p[i].x = x;
p[i].y = y;
}
ans = area_polygon(i);
if (ans < 0)
ans = -ans;
if (ans % 2 == 0)
printf("%I64d\n", ans/2);
else
printf("%I64d.5\n", ans/2);
}
return 0;
}
叉乘求多边形面积
*/
#include <iostream>
#include <cmath>
#define MAXN 1000001
using namespace std;
struct point {
int x;
int y;
} p[MAXN];
__int64 area_polygon(int n)
{
__int64 sum = 0;
for (int i = 0; i < n; i++)
sum += p[(i+1)%n].y * p[i].x - p[(i+1)%n].x * p[i].y;
return sum;
}
int main()
{
int n, i, number;
char num[MAXN];
__int64 x, y, ans;
int go[10][2]={{ 0, 0},
{-1, -1},
{ 0, -1},
{ 1, -1},
{-1, 0},
{ 0, 0},
{ 1, 0},
{-1, 1},
{ 0, 1},
{ 1, 1}};
scanf("%d", &n);
getchar();
p[0].x = 0;
p[1].x = 0;
while (n--)
{
scanf("%s", &num);
if (num[0] == '5')
{
printf("0\n");
continue;
}
x = 0;
y = 0;
for (i = 1; num[i] != '5'; i++)
{
number = num[i] - '0';
x += go[number][0];
y += go[number][1];
p[i].x = x;
p[i].y = y;
}
ans = area_polygon(i);
if (ans < 0)
ans = -ans;
if (ans % 2 == 0)
printf("%I64d\n", ans/2);
else
printf("%I64d.5\n", ans/2);
}
return 0;
}