还是 : 要是用叉积求一个任意多边形的面积 ,多边形必须给定 ! (即顺序要有的)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <string>
#define ll long long
using namespace std;
const double eps = 1e-8;
const int maxn = 1e6 + 10;
ll dx[10] = {0,-1,0,1,-1,0,1,-1,0,1};
ll dy[10] = {0,-1,-1,-1,0,0,0,1,1,1};
ll ab (ll x) {return x > 0 ? x : -x;}
ll cross (ll x1,ll y1,ll x2,ll y2) {
return x1 * y2 - x2 * y1;
}
int main () {
int T;
scanf ("%d",&T);
while (T--) {
ll ans = 0;
ll x = 0,y = 0;
ll px = 0,py = 0;
char str[maxn];
scanf ("%s",str);
for (int i = 0;; ++ i) {
char c = str[i];
if (c == '5') break;
int opt = c - '0';
px = x + dx[opt];
py = y + dy[opt];
ans += cross(x, y, px, py);
x = px,y = py;
}
ans = ab(ans);
if (ans % 2 == 0) printf ("%lld\n",ans / 2);
else printf("%lld.5\n",ans / 2);
}
return 0;
}