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 diesirae at 2011-05-01 22:06:48 on Problem 1282
#include<stdio.h>
int main()
{
	int a[200],b[200][200],i,year=1,p,flag,j,n,k;
	char s[200];
	scanf("%d %d",&n,&p);
	getchar();
	for(i=0;i<n;i++)
	{	gets(s);
		j=0;k=0;

		while(s[k]!=NULL&&j<p)
		{		
			b[i][j]=0;
			while(s[k]!=' '&&s[k]!=NULL)
			{
				b[i][j]*=10;
				b[i][j]+=(s[k]-48);
				
				k++;
			}
		k++;j++;
		}
	}
	for(i=0;i<n;i++)
		a[i]=i;j=0;

	while(year<=1000000000)
	{
		flag=1;
	for(i=0;i<n;i++)
	{	a[i]=b[(a[i])][j]-1;
		if(a[i]!=i)
			flag=0;
	}	
	if(flag)
	{printf("%d\n",year);break;}
	year++;j=(j+1)%p;

	}
	if(year>1000000000)
	printf("No one knows.\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