Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## Re:求高手帮忙看下代码，不知道哪里没有考虑到，一直是WA，我有用__int64,万分感谢

Posted by wang521 at 2009-09-30 21:53:30 on Problem 1654
In Reply To:求高手帮忙看下代码，不知道哪里没有考虑到，一直是WA，我有用__int64,万分感谢 Posted by:Sukileen at 2009-09-03 10:04:10
```> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> #include <math.h>
> char num[1000010];
> int main () {
> 	int cases, i, l;
> 	__int64 s, a, b, x, y;
> 	scanf("%d", &cases);
> 	while(cases--) {
> 		scanf("%s", num);
> 		l = strlen(num);
> 		a = b = x = y = 0;
> 		s = 0;
> 		for(i = 0; i < l; i++) {
> 			if(num[i] == '5')
> 				break;
>             if(num[i] == '8') {
> 				b++;
> 			}
> 			if(num[i] == '2') {
> 			    b--;
> 			}
> 			if(num[i] == '6') {
> 			    a++;
> 			}
> 			if(num[i] == '4') {
> 			    a--;
> 			}
> 			if(num[i] == '9') {
> 			    a++;
> 			    b++;
> 			}
> 		    if(num[i] == '7') {
> 			    a--;
> 			    b++;
> 			}
> 			if(num[i] == '3') {
> 			    a++;
> 			    b--;
> 			}
> 			if(num[i] == '1') {
> 			    a--;
> 			    b--;
> 			}
> 			s = s + x * b - a * y;
> 			x = a;
> 			y = b;
> 			//printf("area:%I64d\n", s);
> 		}
> 		if(s < 0)
> 			s = s * -1;
> 		if(s % 2 == 0)
> 		    printf("%I64d\n", s / 2);
> 		else
> 			printf("%I64d.5\n", s / 2);
> 	}
> 	return 0;
> }

Followed by: