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:求助:怎么才能不超时阿…… Posted by:Amethyst at 2004-12-28 17:19:28 > #include<stdio.h> > void main() > { > int n,i,j; > int a[100000]; > > scanf("%d",&n); > while(n!=-1) > { > a[0] = 0; > for(i=1;i<=n;i++) > { > a[i] = a[i-1] - i; > if(a[i]<=0) > { > a[i] = a[i] + 2*i; > continue; > } > j=0; > while(j<i) > { > if(a[i]==a[j]) > { > a[i] = a[i] + 2*i; > break; > } > j++; > } > } > printf("%d\n",a[n]); > scanf("%d",&n); > } > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator