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

这个也runtime ?

Posted by c_light at 2009-05-25 21:06:12 on Problem 2000
#include<iostream>
using namespace std;

int main()
{
	int a[10000];
	int i,j,k,n;
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	j=1;k=1;a[0]=0;
	for (i=1;i<=10000;i++)
	{
		a[i]=a[i-1]+k;
		if (j==i)
		{
			k++;
			j+=k;
		}
	}
	while (cin>>n && n!=0)
		cout<<n<<" "<<a[n]<<endl;
	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