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

Re:求助!!!sos(why wa!)【附代码】

Posted by ecjtuQX at 2008-08-27 20:09:30 on Problem 3086
In Reply To:求助!!!sos(why wa!)【附代码】 Posted by:chmx at 2008-05-15 10:33:33
#include<stdio.h>
#define M 305
int main()
{
	int a[M];
	int T,i,ans,n;
	int count=1;
	a[0]=0;
	for(i=1;i<=301;i++)
		a[i]=a[i-1]+i;
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d",&n);
		ans=0;
		for(i=1;i<=n;i++)
			ans+=i*a[i+1];
		printf("%d %d %d\n",count++,n,ans);
	}
	return 0;
}


/*
4
3
4
5
10

1 3 45
2 4 105
3 5 210
4 10 2145

*/

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