Follows 10038.c (Total 32 lines):

/* @JUDGE_ID:4461XX 10038 C */
/* A */
#include<stdio.h>
#include<math.h>
#define MAX 3000

int main( void )
{
	int N , n , arr[MAX] , m1 , m2 , yes ;

	while( scanf( "%d" , &N )==1 ){
		memset( arr , 0 , sizeof( arr[0] )*N ) ;
		
		if( N ) scanf( "%d" , &m1 ) ;
		for( yes=1,n=N-1 ; n>0 ; n--,m1=m2 ){
			scanf( "%d" , &m2 ) ;
			
			if( !yes ) continue ;
			if( abs( m1-m2 )==0 || abs( m1-m2 )>=N ) yes = 0 ;
			else
				if( arr[ abs( m1-m2 ) ] ) yes = 0 ;
				else arr[ abs( m1-m2 ) ] = 1 ;

		}

		if( yes ) puts( "Jolly" ) ;
		else puts( "Not jolly" ) ;
	}
	
	return 0 ;
}
/* @END_OF_SOURCE_CODE */

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