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

谁帮我看一下,与别人的正确程序测的n多组数据都一样,为什么我的总wa???!!!

Posted by qinwang at 2009-09-01 13:00:36 on Problem 1969
#include <iostream>
using namespace std;
#include <math.h>
int main()
{
	int n,k,t;
	while(scanf("%d",&n)!=EOF)
	{
		for(k=int(sqrt(2.0*n)-1);;k++)
		{
			if((1+k)*k/2==n)
			{
				if(k%2)
		        	 printf("TERM %d IS 1/%d\n",k,k);
				else
			    	printf("TERM %d IS %d/1\n",n,k);
				break;
			}
			if((1+k)*k/2<n&&(1+k)*(2+k)/2>n)
			{

				t=n-(k+1)*k/2;
				if(k%2)		
					printf("TERM %d IS %d/%d\n",n,t,k+2-t);	
				else
					printf("TERM %d IS %d/%d\n",n,k+2-t,t);
				break;
			}
		}
	}
	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