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

100b不到的代码怎么写的,怎么都写不到200以下

Posted by kyogre at 2017-09-09 11:52:51 on Problem 2000
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int t,a,ans;
	while(cin>>t&&t)
	{
		a=(sqrt(t*2));
		if(((1+a)*a/2)>t)a--;
		ans=a*(a+1)*(2*a+1)/6+(t-(1+a)*a/2)*(a+1);
                cout<<t<<" "<<ans<<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