| ||||||||||
| 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 | |||||||||
公开ac了的代码!~~~ 需要如此的处理最后的结果!!!绝!!!#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
__int64 dic[10][2]={{0,0},{1,-1},{1,0},{1,1},{0,-1},{0,0},{0,1},{-1,-1},{-1,0},{-1,1}};
char str[1000001];
__int64 getarea(__int64 x1,__int64 y1,__int64 x2,__int64 y2)
{
return x1*y2-y1*x2;
}
int main()
{
int n;
__int64 i,len,x1,y1,x2,y2,p;
__int64 area;
cin>>n;
while (n--)
{
scanf("%s",str);
len=strlen(str);
area=0;
x1=0,y1=0;
for (i=0;i<len-1;i++)
{
p=str[i]-'0';
x2=x1+dic[p][0];
y2=y1+dic[p][1];
area+=getarea(x1,y1,x2,y2);
x1=x2;
y1=y2;
}
if(area<0) area=(-1)*area;
__int64 temp=area/2;
if(area!=temp*2)
printf("%I64d.5\n",temp);
else
printf("%I64d\n",temp);
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator