Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

一次 AC ,0MS……滚滚长江…………

Posted by songzhenqi at 2010-07-28 11:30:02 on Problem 2000
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator