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 |
为什么老是runtime error,快崩溃了,谁能告诉我why#include <iostream> using namespace std; #define MAX 50000+10 #define INFINITY 7000010 //标志数组代替循环 int a[MAX+1]; bool exist[INFINITY]; int main() { memset(exist,false,sizeof(exist)); exist[0]=true; a[0]=0; for(int i=1;i<MAX;i++) { if(a[i-1]-i>0 && false==exist[a[i-1]-i]) a[i]=a[i-1]-i; else a[i]=a[i-1]+i; exist[a[i]]=true; } int k; while(1==scanf("%d",&k)&&k>=0) { printf("%d\n",a[k]); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator