Follows 294.c (Total 51 lines):

/* @JUDGE_ID:4461XX 294 C */
/* A */
#include<stdio.h>
#include<math.h>
long prim[3500] ;
void build( void )
{
	long i , point ;
	int j , yes ;
	for( i=2 , point=0 ; point<3500 ; i++ ){
		for( j=2 , yes=1 ; j<=sqrt(i) ; j++ )
			if( !(i%j) ){
				yes = 0 ;
				break ;
			}
		if( yes ) prim[point++] = i ;
	}
}
long run( long n ){
	int used[3500] , i , j ;
	long ans=1 ;
	for( i=0 ; i<3500 ; i++ ) used[i] = 0 ;
	for( i=0 ; n!=1 && i<3500 ; i++ ){
		while( !(n%prim[i]) ){
			n /= prim[i] ;
			used[i]++ ;
		}
	}
	for( j=0 ; j<i ; j++ ) ans *= ( used[j] + 1 ) ;
	if( n!=1 ) ans *= 2 ;
	return ans ;
}
void main( void )
{
	int n , i ;
	long from , to , j , re , bigre , bigj ;
	build() ;
	scanf( "%d" , &n ) ;
	for( i=0 ; i<n ; i++ ){
		scanf( "%ld %ld" , &from , &to  ) ;
		printf( "Between %ld and %ld, " , from , to ) ;
		for( j=from , bigre=0 ; j<=to  ; j++ ){
			re = run( j ) ;
			if( re > bigre ){
				bigre = re ;
				bigj = j ;
			}
		}
		printf( "%ld has a maximum of %ld divisors.\n" , bigj , bigre ) ;
	}
}

Back to statistics
Ya-Lin Huang (C)
huangyl@gmail.com