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

请问1282为什么一直内存溢出?谢谢

Posted by Hence at 2004-03-22 14:08:52 on Problem 1282
#include <stdio.h>

int main()
{
	const int max=200;
	freopen("1282pku.in","r",stdin);
	char a[max][max];
	char r[max];
	long int i,j,n,p;
	long int t1,t2;
	long int year;
	scanf("%ld %ld",&n,&p);
	for (i=0;i<n;i++)
		for (j=0;j<p;j++) {scanf("%ld",&t1);a[i][j]=(int)t1-1;}
	year=0;
	for (i=0;i<n;i++) r[i]=(int)i;
	while (year<1000000000)
	{
		t1=0;t2=year%p;
		for (i=0;i<n;i++)
		{
			r[i]=a[r[i]][t2];
			if (i==r[i]) t1++;
		}
		if (t1==n) break;
		year++;
	}
	if (year==1000000000)  puts("No one knows."); else printf("%d\n",year+1);
}

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