标签:
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 17377 | Accepted: 4827 |
Description
Input
Output
Sample Input
4 5 825 6725 6244865
Sample Output
0 0 0.5 2
Source
#include <cstdio> #include <cstring> const int MAXN = 1000001; char str[MAXN]; int ac[10][2]={0, 0, -1, -1, 0, -1, 1, -1, -1, 0, 0, 0, 1, 0, -1, 1, 0, 1, 1, 1}; int main(){ int T; scanf("%d", &T); while(T--){ scanf("%s", str); long long sum = 0; int a = ac[str[0]-‘0‘][0]; int b = ac[str[0]-‘0‘][1]; for(int i = 1; i < strlen(str); i++){ int c = a + ac[str[i]-‘0‘][0]; int d = b + ac[str[i]-‘0‘][1]; sum += a*d - b*c; a = c; b = d; } if(sum < 0) sum = -sum; printf("%lld", sum/2); if(sum%2) printf(".5"); printf("\n"); } return 0; }
标签:
原文地址:http://www.cnblogs.com/fengshun/p/5074439.html