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 |
最简单的暴力解法,附代码#include<iostream> using namespace std; int main(){ int n; while(cin>>n){ int i,j,k,s; for(i=1;;i++){ for(j=1;;j++){ if(n==i*(1+i)/2-2*j){ cout<<i<<endl; break; } if(i*(1+i)/2-2*j<0) break; } if(n==i*(1+i)/2-2*j) break; } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator