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

呵呵,打了个小表,有点遗憾啊,虽然过了

Posted by kirsten0302 at 2009-08-03 18:25:11 on Problem 2000
#include <iostream>
using namespace std;

int main ()
{
	int k,i,sum=0,sum1=0;
	while (scanf("%d",&k)!=EOF&&(k!=0))
	{	sum=0;
		sum1=0;
		if (k==1) {cout<<k<<' '<<"1"<<endl;continue;}
		if (k==2) {cout<<k<<' '<<"3"<<endl;continue;}
		if (k==3) {cout<<k<<' '<<"5"<<endl;continue;}
		for (i=1;i<=k;i++)
		{
			sum=sum+i;
			if (sum<=k)
			{
				sum1=sum1+i*i;
				continue;
			}else break;
		}


		sum1=sum1+(k-(sum-i))*i;
		cout<<k<<' '<<sum1<<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