Skip to content

Instantly share code, notes, and snippets.

@Abreto
Created April 24, 2013 09:34
Show Gist options
  • Save Abreto/5450958 to your computer and use it in GitHub Desktop.
Save Abreto/5450958 to your computer and use it in GitHub Desktop.
PC110202/UVa10315
/* PC 110201 - Jolly Jumper */
#include <stdio.h>
#include <string.h>
#define ABS(x) ( ((x)>0) ? (x) : (-(x)) )
char bits[3002] = {0};
int main(void)
{
int n = 0;
while( scanf("%d", &n) != EOF )
{
int i = 0;
int d = 0;
int a = 0, b = 0;
memset(bits, 0, 3000);
scanf("%d", &a);
for(i = 1;i < n;++i)
{
scanf("%d", &b);
d = ABS(b-a);
if( d < n )
bits[d] = 1;
a = b;
}
/* is it a 'jolly jumper' */
i = 1;
while( bits[i++] );
/* print the answer. */
if( i >= n )
printf("Jolly\n");
else
printf("Not jolly\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment