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

Posted by hanweify at 2010-05-20 16:35:51 on Problem 2000
#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:
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