Skip to content

Instantly share code, notes, and snippets.

@henrybear327
Last active August 29, 2015 14:08
Show Gist options
  • Save henrybear327/0f18d862d339ac368328 to your computer and use it in GitHub Desktop.
Save henrybear327/0f18d862d339ac368328 to your computer and use it in GitHub Desktop.
ACM10038(using cleaner method).c
#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
*/
/*
check corner case, such as 2 1 1...
*/
int main()
{
int total_cases;
while(scanf("%d", &total_cases)!= EOF)
{
int sequence[3001] = {0};
int answer[3001] = {0};
int index;
for(index = 1; index <= total_cases; index++)
{
scanf("%d", &sequence[index]);
}
int flag = 0;
for(index = 1; index <= total_cases - 1; index++)
{
int difference;
difference = (sequence[index] - sequence[index + 1] >= 0)?sequence[index] - sequence[index + 1]: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