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

如果你们的程序都可以保证返回0表示正常结束

Posted by hawk at 2004-03-22 15:15:30 on Problem 1282
In Reply To:请问1282为什么一直内存溢出?谢谢 Posted by:Hence at 2004-03-22 14:08:52
那我就容易判断了
可惜vc可以不返回值,所以目前是通过错误代码来判断的
而windows系统那个时候不给我返回runtime error,而是内存溢出
可能是由于你的是局部变量,系统就不算内存访问错了,郁闷.

> #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