| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
while always runtime error,请大哥指教……#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator