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:use 64-bit integer, BIIIIIIIIIIIIIIIIIIIIIG TRAP

Posted by Windows2k at 2005-06-02 12:38:59 on Problem 2444
In Reply To:use 64-bit integer, BIIIIIIIIIIIIIIIIIIIIIG TRAP Posted by:frkstyc at 2005-06-02 10:05:05
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long int _int64;
_int64 a[501][501],b[501][501];
_int64 abs(_int64 a) { return (a>0) ? a : -a; }
int m,n;
int main()
{
	while(scanf("%d %d",&m,&n)==2) {
		if(!m&&!n) break;
		_int64 min=(_int64)65535*500*500;
		for(int i=1;i<=m;i++)
			for(int j=1;j<=n;j++) scanf("%lld",&a[i][j]);
		for(int i=1;i<=m;i++)
			for(int j=1;j<=n;j++) b[i][j]=b[i-1][j]+b[i][j-1]-b[i-1][j-1]+a[i][j];
		for(int i=1;i<m;i++)
			for(int j=1;j<n;j++) {
				_int64 x=b[i][j],y=b[m][j]-b[i][j],
				    z=b[m][n]-b[m][j];
				_int64 t=abs(x-y)+abs(y-z)+abs(z-x);
				if(t<min) min=t;
			}
		printf("%lld\n",min);
	}
}
--
I have use 64-bit before, still get WA

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