| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
i think perhaps you have missed some casesIn Reply To:Re:use 64-bit integer, BIIIIIIIIIIIIIIIIIIIIIG TRAP Posted by:Windows2k at 2005-06-02 12:38:59 > #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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator