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 |
大数组要是全局的In Reply To:疯了疯了,怎么总是RE! Posted by:Manio at 2006-09-19 11:56:09 > #include <iostream> > using namespace std; > #define RSIZE 50000000 > #define ASIZE 5000000 > int main() > { > bool rec[RSIZE]; > long a[ASIZE]; > long i; > for (i=0;i<RSIZE;i++) > rec[i]=false; > for (i=0;i<ASIZE;i++) > a[i]=0; > a[0]=0; > for (i=1;i<ASIZE;i++) > { > a[i]=a[i-1]-i; > if(a[i]<=0 || rec[a[i]]==true) > a[i]=a[i-1]+i; > rec[a[i]]=true; > } > long n; > while(cin>>n) > { > if(n==-1)return 0; > cout<<a[n]<<endl; > } > return 0; > > } > Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator