| ||||||||||
| 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 | |||||||||
16ms今天好高兴#include "iostream"
#include "string.h"
using namespace std;
struct p
{
int x,y;
};
int square(p a,p b,p c)
{
int r = (b.x-a.x)*(c.y-b.y)-(b.y-a.y)*(c.x-b.x);
return r;
}
int main()
{
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
int n;
int move[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);
char ch[1000100];
while(n--)
{
scanf("%s",ch);
int len = strlen(ch);
int i,j,k;
p a,b,c;
a.x=0,a.y=0;
c.x=a.x+move[ch[0]-'0'][0];
c.y=a.y+move[ch[0]-'0'][1];
__int64 s =0;
for(i=1;i<len;i++)
{
b=c;
c.x=b.x+move[ch[i]-'0'][0];
c.y=b.y+move[ch[i]-'0'][1];
s+=square(a,b,c);
}
if(s<0)s=-s;
printf("%I64d",s/2);
if(s%2)
printf(".5");
printf("\n");
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator