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

while always runtime error,请大哥指教……

Posted by tcx at 2005-07-18 19:57:25 on Problem 2081
#define M1 500001
#define M2 2000000
#include "stdio.h"
int main()
{ long a[M1+1],i,temp,n;
  short rec[M2+1];
  for(i=0;i<=M2;i++) rec[i]=0;
  a[0]=0; rec[0]=1;
  for(i=1;i<=M1;i++)
     {	temp=a[i-1]-i;
	if (temp<=0)
	 { a[i]=a[i-1]+i;  rec[a[i]]=1;}
	else {	if (rec[temp])
	          { a[i]=a[i-1]+i; rec[a[i]]=1;}
		else { a[i]=temp; rec[temp]=1;}
	     }
      }
  scanf("%ld",&n);
 while (n!=-1)
  { printf("%ld\n",a[n]);
    scanf("%ld",&n);
  }
  return 0;
}

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