#include <stdio.h> #include <math.h> int main(int argc, char* argv[]) { int counter; int num[3000]; int flag[3000]; while( scanf("%d", &counter) == 1 ){ int i; for(i = 0 ; i < counter ; i++){ scanf("%d", &num[i]); flag[i] = 0; } int res = 0; for(i = 1 ; i < counter ; i++){ int diff; if(num[i] > num[i-1]){ diff = num[i] - num[i-1]; }else{ diff = num[i-1] - num[i]; } if(0 < diff && diff < counter){ if(flag[diff] == 0){ flag[diff] = 1; }else{ res = 1; break; } }else{ res = 1; break; } } if( res == 1 ){ printf("Not jolly\n"); } else{ printf("Jolly\n"); } } return 0; }
No comments:
Post a Comment