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:这题怎么做啊?

Posted by kirsten0302 at 2009-08-07 17:22:46 on Problem 3086
In Reply To:这题怎么做啊? Posted by:xh176233756 at 2007-02-22 17:20:47
#include <iostream>
using namespace std;


int sum (int n)
{
	int sum1=0,i;
	for (i=1;i<=n;i++)
	{
		sum1=sum1+i;
	}
	return sum1;
}
int a[1000];
int main ()
{
	int k,i=0,j,sum2;
	cin>>k;
	while (k--)
	{
		cin>>a[i];
		sum2=0;
		for (j=1;j<=a[i];j++)
		{
			sum2=sum2+j*sum(j+1);
		
		}
		cout<<i+1<<' '<<a[i]<<' '<<sum2<<endl;
		i++;

	}
	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