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

代码

Posted by 476430644 at 2009-05-10 13:00:00 on Problem 1969
In Reply To:为啥就是不过呢??55555555555555555 Posted by:raidou at 2004-12-27 19:27:43
#include<iostream>
using namespace std;
int main()
{
	int n,i,a,b,m;
	while(scanf("%d",&n)!=EOF)
	{
m=0;
		for(i=1;m==0;i++)
		{
			if(n==(i+1)*i/2)
			{
				if(i%2==1)
				{
				a=1;
				b=i;
				m=1;
				}
				else
                {
					a=i;
					b=1;
					m=1;
				}
			}
               if(n>(i+1)*i/2&&n<(i+1)*(i+2)/2)
			   {
				   if(i%2==1)
				   {
					   a=n-(i+1)*i/2;
					   b=i+2-a;
					   m=1;
				   }
				   else
				   {
					   b=n-(i+1)*i/2;
					   a=i+2-b;
					   m=1;
				   }
			   }
		}
		cout<<"TERM "<<n<<" IS "<<a<<"/"<<b<<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