Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  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;
> }
把a,b,x,y全变成int64 就可以过了

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator