Follows 151.c (Total 52 lines):

/* @JUDGE_ID:4461XX 151 C */
/* A */
#include<stdio.h>
struct city{
	int from ;
	int off ;
	int next ;
}city[100] ;
void first( int n )
{
	int i ;
	for( i=0 ; i<n ; i++ ){
		city[i].from = (i-1+n)%n ;
		city[i].next = (i+1)%n ;
		city[i].off = 0 ;
	}
}
int off( int n , int m )
{
	int i , j , offed ;
	j=0 ;
	for( i=city[0].next , offed=1 ; offed!=n-1 ; i=city[i].next ){
		if( !city[i].off ){
			j++ ;
			if( j == m ){
				if( i == 12 ) return 0 ;
				city[i].off = 1 ;
				city[city[i].next].from = city[i].from ;
				city[city[i].from].next = city[i].next ;
				j = 0 ;
				offed++ ;
			}
		}
	}
	return 1 ;
}
void main( void )
{
	int n , i ;
	while( 1 ){
		scanf( "%d" , &n ) ;
		if( !n ) break ;
		for( i=1 ; ; i++ ){
			first( n ) ;
			city[0].off = 1 ;
			if( off( n , i ) ){
				printf( "%d\n" , i ) ;
				break ;
			}
		}
	}
}

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