Follows 10127.c (Total 30 lines):

/* @JUDGE_ID:4461XX 10127 C "MATH" */
/* A */
#include<stdio.h>
#include<string.h>
#define MAX 10000

int main( void )
{
	int n , count , tmp_n , data[MAX+1] ;

	memset( data , -1 , sizeof( data ) ) ;
	while( scanf( "%d" , &n )==1 ){
		if( data[n]==-1 ){
			for( tmp_n=n,count=0 ; ; ){
				while( tmp_n%10==1 ){
					tmp_n /= 10 ;
					count++ ;
				}
				if( !tmp_n ) break ;
				tmp_n += n ;
			}
			data[n] = count ;
		}
		
		printf( "%d\n" , data[n] ) ;
	}
	
	return 0 ;
}
/* @END_OF_SOURCE_CODE */

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