Skip to content

Instantly share code, notes, and snippets.

@amoshyc
Last active August 29, 2015 14:08
Show Gist options
  • Save amoshyc/a682a19338d041a33679 to your computer and use it in GitHub Desktop.
Save amoshyc/a682a19338d041a33679 to your computer and use it in GitHub Desktop.
uva10038.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
int N;
while (scanf("%d", &N) != EOF) {
int data[N];
int i;
for (i=0; i<N; i++)
scanf("%d", &data[i]);
int check[N+1];
memset(check, 0, sizeof(check));
for (i=0; i<N-1; i++)
if (abs(data[i+1] - data[i]) < N)
check[abs(data[i+1] - data[i])] = 1;
int flag = 1;
for (i=1; i<N; i++) {
if (check[i] == 0) {
flag = 0;
break;
}
}
if (flag == 1)
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