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 |
测试好多数据都对了为什么还WA啊.....................#include<stdio.h> #include<stdlib.h> #include<math.h> struct Point{ int x; int y; }point[1000000+100]; char str[1000000+100]; main() { int t,i; long long j,count=0,k; long long s=0; scanf("%d",&t); for(i=1;i<=t;i++){ scanf("%s",str); point[0].x=0; point[0].y=0; count=0; for(k=1,j=0;str[j]!='5';j++,k++){ count++; if(str[j]=='8'){ point[k].x=point[k-1].x; point[k].y=point[k-1].y+1; } if(str[j]=='2'){ point[k].x=point[k-1].x; point[k].y=point[k-1].y-1; } if(str[j]=='6'){ point[k].x=point[k-1].x+1; point[k].y=point[k-1].y; } if(str[j]=='4'){ point[k].x=point[k-1].x-1; point[k].y=point[k-1].y; } if(str[j]=='9'){ point[k].x=point[k-1].x+1; point[k].x=point[k-1].y+1; } if(str[j]=='7'){ point[k].x=point[k-1].x-1; point[k].y=point[k-1].y+1; } if(str[j]=='3'){ point[k].x=point[k-1].x+1; point[k].y=point[k-1].y+1; } if(str[j]=='1'){ point[k].x=point[k-1].x-1; point[k].y=point[k-1].y-1; } } s=0; if(count<=1) printf("0\n"); else{ for(k=1;k<=count;k++){ s=s+point[k].x*point[k+1].y-point[k].y*point[k+1].x; } s=abs(s); if(s%2==0) printf("%lld\n",s/2); else{ printf("%1ld.5\n",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