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 SoEnLit at 2012-05-20 09:48:22 on Problem 2000
#include<stdio.h>

int main()
{
	freopen("D:/ACMData.txt","r",stdin);
	int n;
	for(scanf("%d",&n);n;scanf("%d",&n))
	{
		int i=1;
		int k;
		long sum = n;
		for(k = i; k<n; i++, k = (1+i)*i/2)//k为等差数列前n项和
		{
			sum += n-k;
		}
		printf("%d %ld\n",n,sum);
	}
	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