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

怎么又wa了,谁能帮看一下。我是新手

Posted by 416458882 at 2008-04-29 11:39:33 on Problem 1282
#include<stdio.h>

int ss(void);
void bb(int p,int q);
int a[202][202];
int b[200];
int k=-1;
int i,j,m,n;
int max=0;
int s=0;


int main(void)
{
	scanf("%d%d",&m,&n);
	for(i=1;i<=m;i++)
		{
		for(j=0;j<n;j++)
		{   
			int number;
		    scanf("%d",&number);
			a[i][j]=number;
		}
	}
	i=1;
	while(i<=m)
	{
		bb(i,0);
		++i;
	}
	if(s==0)
		printf("%d",ss());

	return 0;
}

void bb(int p,int q)
{   
	k++;
	if((p==i)&&(q==0)&&(k!=0))
	{   
		if(k>max)
			(max=k);
		b[i]=k;

		k=-1;
	}
	else if(k>10000000)
	{  
		printf("No one knows.");
		s=1;
	}
	else
	{
		p=a[p][q];
		q=(q+1)%n;
		bb(p,q);
	}
}

int ss(void)
{
	while(1)
	{
		int i=1;
		while(max%b[i]==0)
		{
			i++;
			if(i>m)
			{
				return max;
			}
		}
		max++;
	}
}


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