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

trouble

Posted by huicpc11 at 2005-08-17 14:37:07 on Problem 2590
#include <stdio.h>
#include <math.h>

long a,b;

long process( void );

int main()
{
	int sum ;
	int i, j ;
	while( scanf( "%d" , &sum ) == 1 )
	{	for( j=0 ; j < sum ; j++){
			scanf( "%ld%ld", &a, &b );
			printf( "%ld" , process() ) ;
			printf("\n");
		}
	}
	return 0;
}

long process( void )
{
	long i;
	long length = b - a ;
	printf( "length=%ld " , length ) ;
	long mid = sqrt(length) ;
	printf( "mid=%ld" , mid ) ;
	
	if ( length==0 ) return 0;
	if ( length==1 ) return 1;
	if ( length>mid*mid && length<= mid*(mid+1) ) return 2*mid-1;
	if ( length<=(mid+1)*(mid+1) && length> mid*(mid+1) ) return 2*mid;
	
}

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