Created
April 24, 2013 09:34
-
-
Save Abreto/5450958 to your computer and use it in GitHub Desktop.
PC110202/UVa10315
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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