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:why I always WA?In Reply To:why I always WA? Posted by:lcftc at 2004-09-26 16:48:43 > #include<iostream> > using namespace std; > int main(){ > unsigned long N; > while(cin>>N){ > > unsigned long sum=0; > unsigned long i; > for(i=1;;i++){ > sum+=i; > if(sum>=N) > break; > } > unsigned int n; > if(sum==N){ > n=i; > }else{ > unsigned long x=sum-N; > if(x%2==0){ > n=i; > }else{ > n=i+2; > } > if(x==1){ > n=i+1; > } > } > cout<<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