Follows 160.c (Total 41 lines):

/* @JUDGE_ID:4461XX 160 C */
/* A */
#include <stdio.h>
void swap( int *i , int *j )
{
	int temp ;
	temp = *i ;
	*i = *j ;
	*j = temp ;
}
void main( void )
{
	int num[20000] , n ;
	while( scanf( "%d" , &n )==1 )
	{
		int k=0 , i , j , top , times , ptimes ;
		if( n==0 ) break ;
		for( i=0 ; i<20000 ; i++ ) num[i] = 0 ;
		for( i=2 ; i<=n ; i++ )
		{
			j = i ; top=2 ;
			while( j>1 )
			{
				if( j%top==0 ) { num[k] = top ; k++ ; j /= top ; }
				else top++ ;
			}
		}
		for( i=0 ; i<k-1 ; i++ )
			for( j=i+1 ; j<k ; j++ )
				if( num[i]>num[j] ) swap( &num[i] , &num[j] ) ;
		times = 0 ; ptimes = 0 ;
		printf( "%3d! =" , n ) ;
		for( i=0 ; i<k ; i++ )
		{
			if( num[i]==num[i+1] ) times++ ;
			else { printf( "%3d" , times+1 ) ; times = 0 ; ptimes++ ; }
			if( ptimes==15 && i+1<k ) printf( "\n      " ) ;
		}
		printf( "\n" ) ;
	}
}

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