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 |
一次AC#include<iostream> using namespace std; int main() { int i,j,k,sum,sum1,N; while(1) { cin>>N; if(N==0) break; else { for(i=1;;i++) { sum=0; sum1=0; for(j=1;j<=i;j++) sum+=j; if(N<=sum) { for(k=1;k<=i-1;k++) sum1+=k*k; sum1+=i*(N-sum+i); cout<<N<<" "; cout<<sum1<<endl; 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