Follows 10219.c (Total 22 lines):

/* @JUDGE_ID:4461XX 10219 C "math-log10()" */
/* A */
#include<math.h>
#include<stdio.h>

int main( void )
{
	int n , k , i ;
	double ans ;

	while( scanf( "%d %d" , &n , &k )==2 ){
		if( n-k<k ) k = n-k ;
		ans = 0.0 ;
		
		for( i=0 ; i<k ; ++i ) ans += log10( (double)( n-i ) ) ;
		for( i=1 ; i<=k ; ++i ) ans -= log10( (double)( i ) ) ;

		printf( "%d\n" , (int)( ans+1.0 ) ) ;
	}

	return 0 ;
}

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