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

哥哥姐姐们,帮帮忙看看这个的输出格式有什么问题没? 问题2000

Posted by Binnary at 2006-04-26 18:42:38
#include <iostream.h>

int calculator(int n)
{
	return (n*(n+1)*(2*n+1)/6);
}

int get_value(int i)
{
	int j=1;
	while(1)
	{		
		if((j+1)*j/2>i)
			break;
		j++;
	}
	
	int sum=calculator(j-1);
	
	sum+=j*(i-(j-1)*j/2);
	return sum;
}

void main()
{
	int i;
	cin>>i;
	cout<<i;
	cout<<get_value(i);
}


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