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: 0msAC

Posted by wolf5x at 2009-08-25 18:26:08 on Problem 1969
In Reply To: 0msAC Posted by:ylllxw08 at 2009-08-15 23:16:23
佩服,
if(int==double)
你也敢用...

> #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