Created
October 27, 2014 09:20
-
-
Save henrybear327/e2c3904b3abb59cf63a8 to your computer and use it in GitHub Desktop.
ACM10038.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> | |
/* | |
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=&problem=979&mosmsg=Submission+received+with+ID+14429995 | |
*/ | |
int main() | |
{ | |
int total_cases; | |
while(scanf("%d", &total_cases)!= EOF) | |
{ | |
int sequence[3001]; | |
int answer[3001]; | |
int index; | |
for(index = 1; index <= total_cases; index++) | |
{ | |
answer[index] = 0; /*assign 0 to every answer*/ | |
} | |
for(index = 1; index <= total_cases; index++) | |
{ | |
scanf("%d", &sequence[index]); | |
} | |
int flag = 0; | |
for(index = 1; index <= total_cases - 1; index++) | |
{ | |
int difference; | |
if(sequence[index] - sequence[index + 1] >= 0) | |
difference = sequence[index] - sequence[index + 1]; | |
else | |
difference = sequence[index + 1] - sequence[index]; | |
answer[difference]++; | |
} | |
for(index = 1; index < total_cases; index++) | |
{ | |
if(answer[index] == 0) | |
{ | |
flag = 1; | |
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