第一个几何题目。
叉积求面积。
/*
* Author: stormdpzh
* Created Time: 2012/7/19 12:49:54
* File Name: poj_1654.cpp
*/
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#define sz(v) ((int)(v).size())
#define rep(i, n) for(int i = 0; i < n; i++)
#define repf(i, a, b) for(int i = a; i <= b; i++)
#define repd(i, a, b) for(int i = a; i >= b; i--)
#define out(n) printf("%d\n", n)
#define mset(a, b) memset(a, b, sizeof(a))
#define wh(n) while(1 == scanf("%d", &n))
#define whz(n) while(1 == scanf("%d", &n) && n != 0)
#define lint long long
using namespace std;
const int MaxN = 1 << 30;
struct Point
{
lint x, y;
Point() {}
Point(lint _x, lint _y) : x(_x), y(_y) {}
};
Point operator + (const Point &p1, const Point &p2)
{
return Point(p1.x + p2.x, p1.y + p2.y);
}
lint operator * (const Point &p1, const Point &p2)
{
return (p1.x * p2.y - p2.x * p1.y);
}
string str;
Point pre;
void gao()
{
lint area = 0;
rep(i, sz(str)) {
Point now;
bool flag = false;
switch(str[i]) {
case '8': now = pre + Point(0, 1);
break;
case '2': now = pre + Point(0, -1);
break;
case '4': now = pre + Point(-1, 0);
break;
case '6': now = pre + Point(1, 0);
break;
case '9': now = pre + Point(1, 1);
break;
case '7': now = pre + Point(-1, 1);
break;
case '1': now = pre + Point(-1, -1);
break;
case '3': now = pre + Point(1, -1);
break;
case '5': flag = true;
break;
}
if(flag) break;
area += (pre * now);
pre = Point(now.x, now.y);
}
if(area < 0) area = -area;
if(area & 1)
cout << area / 2 << ".5" << endl;
else
cout << area / 2 << endl;
}
int main()
{
int t;
scanf("%d", &t);
while(t--) {
cin >> str;
pre = Point(0, 0);
gao();
}
return 0;
}