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 啊?请高手帮帮忙看看(附程序)

Posted by ericsummer at 2005-11-10 14:32:03 on Problem 2704
In Reply To:注意的是,结果用__int64存储才不会溢出。 Posted by:ACM30021 at 2005-11-09 21:48:50
#include <stdio.h>
#include <iostream.h>
#define maxn 35

char a[maxn][maxn];
_int64 f[maxn][maxn];



int n;

int main()
{
	int i ,j ,k , m;
	while(cin>>n &&n!=-1)
	{
		for(i=1 ; i<=n ; i++)
			for(j=1 ;j<=n ;j++)
			{
				cin >> a[i][j];
				f[i][j]=0;
			}
			f[1][1] =1;
        for(i=1 ; i<=n ;i++)
		{
			for(j=1 ; j<=n ;j++)
			{
				for(k =1 ; k<=i-1 ;k++)
					if(i-k==a[k][j]-'0')
						f[i][j] += f[k][j];
                for(m =1 ; m<=j-1 ;m++)
					if(j-m == a[i][m]-'0')
						f[i][j] += f[i][m];
			}
		}

		printf("%lld\n" , f[n][n]);
	}
	return 0;
	
}


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