很水的题。。
然后注意用上longlong,否则可能答案会不对。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define DOR(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define oo 1e6
#define eps 1e-8
#define nMax 1000010
#define pb push_back
#define F first
#define S second
#define bug puts("OOOOh.....");
#define zero(x) (((x)>0?(x):-(x))<eps)
#define LL long long
#define DB double
int dcmp(double x){
if(fabs(x)<eps) return 0;
return x>0?1:-1;
}
class point {
public:
double x,y;
point (double x=0,double y=0):x(x),y(y) {}
void make(double _x,double _y) {x=_x;y=_y;}
void read() { scanf("%lf%lf",&x,&y); }
void out() { printf("%.2lf %.2lf\n",x,y);}
double len() { return sqrt(x*x+y*y); }
point friend operator - (point const& u,point const& v) {
return point(u.x-v.x,u.y-v.y);
}
point friend operator + (point const& u,point const& v) {
return point(u.x+v.x,u.y+v.y);
}
double friend operator * (point const& u,point const& v) {
return u.x*v.y-u.y*v.x;
}
double friend operator ^ (point const& u,point const& v) {
return u.x*v.x+u.y*v.y;
}
point friend operator * (point const& u,double const& k) {
return point(u.x*k,u.y*k);
}
friend bool operator < (point const& u,point const& v){
if(dcmp(v.x-u.x)==0) return dcmp(u.y-v.y)<0;
return dcmp(u.x-v.x)<0;
}
friend bool operator != (point const& u,point const& v){
return dcmp(u.x-v.x) || dcmp(u.y-v.y);
}
};
typedef class line{
public:
point a,b;
line() {}
line (point a,point b):a(a),b(b){}
void make(point u,point v) {a=u;b=v;}
void read() { a.read(),b.read(); }
}segment;
int dx[]={0,-1,-1,-1,0,0,0,1,1,1};
int dy[]={0,-1,0,1,-1,0,1,-1,0,1};
char s[nMax];
int main(){
//freopen("input.txt","r",stdin);
int t;
scanf("%d",&t);
while(t--){
scanf("%s",s);
int l=strlen(s);
for(int i=0;i<l;i++) s[i]-='0';
LL ans=0;
LL x,y;
if(l>2){
l--;
x=dx[s[0]],y=dy[s[0]];
for(int i=1;i<l;i++){
ans += x*dy[s[i]]-y*dx[s[i]];
x+=dx[s[i]];
y+=dy[s[i]];
}
}
if(ans<0) ans=-ans;
if(ans&1)printf("%I64d.5\n",ans/2);
else printf("%I64d\n",ans/2);
}
return 0;
}