Follows 550.c (Total 16 lines):

/* @JUDGE_ID:4461XX 550 C */
/* A */
#include <stdio.h>
void main( void )
{
	int sys , over , num ;
	while( scanf( "%d %d %d" , &sys , &num , &over )==3 ){
		int i=0 , n=num ;
		while( 1 ){
			if( n%over==0 && n/over==num ) break ;
			n = ( n % over ) * sys + n/over ;
			i++ ;
		}
		printf( "%d\n" , i+1 ) ;
	}
}

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