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

0msAC

Posted by ylllxw08 at 2009-08-15 23:16:23 on Problem 1969 and last updated at 2009-08-15 23:16:55
In Reply To:Re:水,用数学水之 Posted by:_leaf_ at 2009-07-29 00:12:15
> 如何用数学水啊~~~~~O(1)了都。。。。
#include<iostream>
#include<math.h>
using namespace std;
int fun(int n)
{
	double k;
	k=sqrt(double(2)*n+0.25)-0.5;
	if(k==int(k))
		return int(k)-1;
	else
		return int(k);
}
int main()
{
	int k,m,n;
	while(cin>>n)
	{
		k=fun(n);
		m=n-k*(k+1)/2;
		if(k%2)
			cout<<"TERM "<<n<<" IS "<<m<<'/'<<k+2-m<<endl;
		else
			cout<<"TERM "<<n<<" IS "<<k+2-m<<'/'<<m<<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