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

请高人指点一下,本人用的是广度搜索,测试数据已通过(附上代码)

Posted by hbu_zyx at 2006-08-18 10:13:39 on Problem 2704
#include "stdio.h"
#include "string.h"
void main()
{
	int i,j,n;
	int a[35][35],b[35][35];
	scanf("%d",&n);
	while(n!=-1)
	{
		for(i=1;i<=n;i++)
			for(j=1;j<=n;j++)
				scanf("%1d",&a[i][j]);
		memset(b,0,sizeof(b));
		b[1][1]=1;
		for(i=1;i<=n;i++)
			for(j=1;j<=n;j++)
			{
				if(a[i][j]==0)
					continue;
				if(a[i][j]+j<=n)
					b[i][j+a[i][j]]+=b[i][j];
				if(a[i][j]+i<=n)
					b[a[i][j]+i][j]+=b[i][j];

			}
		printf("%d\n",b[n][n]);
		scanf("%d",&n);  		
	}

}

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