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

各位大哥帮帮忙,为什么wrong answer???

Posted by 00411082 at 2005-04-27 15:47:57 on Problem 1969
#include<iostream.h>
void main()
{
	double a[10000],b;
	int j;
	a[0]=1;
	for(int i=1;i<10000;i++)
	{
		a[i]=i+1+a[i-1];
	}
	while(cin>>b)
	{
		if(b==1) cout<<"TERM 1 IS 1/1"<<endl;
		else{
		for(j=0;;j++)
		{
			if(a[j]>=b) break;
		}
		if((j+2)%2==0)
		{
			cout<<"TERM "<<b<<" IS "<<j+2-b+a[j-1]<<"/"<<b-a[j-1]<<endl;
		}
		if((j+2)%2!=0)
		{
			cout<<"TERM "<<b<<" IS "<<b-a[j-1]<<"/"<<j+2-b+a[j-1]<<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