| ||||||||||
| 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 ,0MS……滚滚长江…………#include <iostream>
using namespace std;
int main()
{ //freopen("in.txt","r",stdin);
int n;
while(cin>>n&&n!=0)
{
int sum=0,days=1;
int i;
for(i=1;days<=n;i++)
{
sum=sum+i*i;
days=days+(i+1);
//cout<<i<<" "<<sum<<" "<<days<<endl;
}
sum=sum+(n+i-days)*i;
cout<<n<<" "<<sum<<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