| ||||||||||
| 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>
#include<cstring>
using namespace std;
int main(){
int dd; cin>>dd;
while(dd!=0){
int I = 1, D = 0, S = 0;
while(D + I <= dd){
S += I*I;
D += I;
I ++;
}
S += (dd - D) * (I);
cout<<dd<<' '<<S<<endl;
cin>>dd;
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator