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 xiaok at 2009-06-07 02:36:01 on Problem 2000
int f(int n)
{
	int k;
	int i;
	int sum;
	k=1;
	while((1+k)*(2+k)/2<n)
		k++;
	sum=0;
	for(i=1;i<=k;i++)
		sum+=((i+k)*(k-i+1)/2);
	sum+=((n-k*(k+1)/2)*(k+1));
	return sum;
}

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