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:这不是真的把?有那么复杂吗?我的程序Memory: 204K Time: 0MS

Posted by hustzh at 2009-05-15 15:10:44 on Problem 2000
In Reply To:呵呵,只要考虑清楚了,用一个数组就搞定了,175ms搞定。好高兴了! Posted by:RMJ87 at 2008-04-18 22:04:31
Source Code

Problem: 2000  User: hustzh 
Memory: 204K  Time: 0MS 
Language: C++  Result: Accepted 

Source Code 
#include <cstdio>
int main()
{
	int d;
	int s1,s2,i;
	while(scanf("%d",&d) != EOF,d)
	{
		for(s1 = s2 = 0,i = 1;s2 < d;i ++)
		{
			s1 += i*i;
			s2 += i;
		}
		if(d != s2)
			s1 += (d-s2)*(i-1);
		printf("%d %d\n",d,s1);
	}
	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