Last active
August 29, 2015 14:08
-
-
Save amoshyc/a682a19338d041a33679 to your computer and use it in GitHub Desktop.
uva10038.c
This file contains hidden or 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
#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