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 |
Re:用空间换时间0ms 5257kbIn Reply To:用空间换时间0ms 5257kb Posted by:12619 at 2009-08-20 16:40:27 > #include<stdio.h> > #include<string.h> > #define Size 500000 > int a[Size+5]; > char exist[Size*10]; > int main() > { > int i,k; > a[0]=0; > memset(a,0,sizeof(exist)); > exist[0]=1; > for(i=1;i<=Size;i++) > { > if(a[i-1]-i<=0||exist[a[i-1]-i]==1) > a[i]=a[i-1]+i; > else > a[i]=a[i-1]-i; > exist[a[i]]=1; > } > while(scanf("%d",&k),k!=-1) > 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