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 200530740317 at 2006-08-20 10:49:15 on Problem 2000
In Reply To:靠,这么简单的题目也会有问题!不要用模拟法。还是数学方法好。 Posted by:huicpc15 at 2005-11-06 16:43:56
我的数学方法
#include<iostream>
using namespace std;
#include<math.h>
main()
{
	int n,m,c;
	while(cin>>n&&n!=0)
	{
		m=(int)(sqrt(8*n+1)-1)/2;
		c=m*(m+1)*(2*m+1)/6+(n-m*(m+1)/2)*(m+1);
		cout<<n<<" "<<c<<endl;
	}
}

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