标签:
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 18499 | Accepted: 5094 |
Description
Input
Output
Sample Input
4
5
825
6725
6244865
Sample Output
0
0
0.5
2
Source
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<cmath> 6 using namespace std; 7 int mx[10]={0,1,1,1,0,0,0,-1,-1,-1}, 8 my[10]={0,-1,0,1,-1,0,1,-1,0,1}; 9 long long s; 10 int x,y; 11 long long area(int x1,int y1,int x2,int y2){//叉积求面积 12 return x1*y2-x2*y1; 13 14 } 15 int main(){ 16 int T; 17 scanf("%d\n",&T); 18 while(T--){ 19 char str[1000010]; 20 scanf("%s",str); 21 s=0; 22 x=0;y=0; 23 int len=strlen(str); 24 // 25 if(len<3){ 26 printf("0\n"); 27 continue; 28 } 29 // 30 for(int i=0;i<len;i++){ 31 int num=str[i]-‘0‘; 32 int nowx=x+mx[num]; 33 int nowy=y+my[num]; 34 s+=area(x,y,nowx,nowy); 35 x=nowx; 36 y=nowy; 37 } 38 if(s<0)s=-s; 39 if(s&1){ 40 printf("%lld.5\n",s/2); 41 } 42 else printf("%lld\n",s/2); 43 } 44 return 0; 45 }
标签:
原文地址:http://www.cnblogs.com/SilverNebula/p/5657320.html