| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
多快好省#define Abs(a) (a<0)?(-a):(a)
inline int xmult(int x1, int y1, int x2, int y2, int x0, int y0) {
return (x1 - x0)*(y2 - y0)-(x2 - x0)*(y1 - y0);
}
int cx[] = {0, -1, -1, -1, 0, 0, 0, 1, 1, 1};
int cy[] = {0, -1, 0, 1, -1, 0, 1, -1, 0, 1};
char ch[1000005];
int main() {
int n, i, T;
long long s;
int x = 0, y = 0, xx, yy, xxx, yyy;
scanf("%d", &T);
while (T--) {
s=0;
scanf("%s", ch);
int l = strlen(ch) - 1;
xxx = cx[ch[0] - '0'];
yyy = cy[ch[0] - '0'];
for (int i = 1; i < l; ++i) {
xx = xxx;
yy = yyy;
xxx += cx[ch[i] - '0'];
yyy += cy[ch[i] - '0'];
s += xmult(x, y, xx, yy, xxx, yyy);
}
printf((s & 1LL) ? "%lld.5\n" : "%lld\n", Abs(s/2));
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator