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 |
伟哥神牛In Reply To:跑了32MS,有兴趣的看看 Posted by:gtzygtzy at 2009-09-18 20:30:52 > #include<iostream> > using namespace std; > char in[1000010]; > struct point > { > int x,y; > }pre,now; > int cx[]={0,-1,-1,-1,0,0,0,1,1,1}; > int cy[]={0,-1,0,1,-1,0,1,-1,0,1}; > int main() > { > int test,i; > __int64 re; > scanf("%d",&test); > while(test--) > { > scanf("%s",in); > i=0; > pre.x=0;pre.y=0; > now.x=0;now.y=0; > re=0; > while(in[i]!='5') > { > if(i>0 && in[i]!=in[i-1]) > { > re+=pre.x*now.y-pre.y*now.x; > pre=now; > now.x=now.x+cx[in[i]-'0']; > now.y=now.y+cy[in[i]-'0']; > } > else > { > now.x=now.x+cx[in[i]-'0']; > now.y=now.y+cy[in[i]-'0']; > } > i++; > } > pre.x=0;pre.y=0; > re+=pre.x*now.y-pre.y*now.x; > if(re<0) re=-re; > if(re%2) printf("%I64d.5\n",re/2); > else printf("%I64d\n",re/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