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 |
各位给我看看程序吧;俺郁闷!!!!!!!!!//我在vc上不能运行,但是把数组改小点就能行了。可是改小了又不满足题目要求。。求救。 #include<stdio.h> #include<iostream.h> void main() { long a,i,j; long m[50000]; while(1) { cin>>a; if(a==-1) break; for(i=0;i<50000;i++) m[i]=0; for(i=1;i<=a;i++) { m[i]=m[i-1]-i; if(m[i]<=0) {m[i]=m[i-1]+i;continue;} for(j=0;j<i;j++) { if(m[j]==m[i]) { m[i]=m[i-1]+i; break; } } } cout<<m[a]<<endl; } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator