(UVA)10038-jolly

#include <stdio.h>
#include <math.h>
#include<stdbool.h>
int main()
{
 int N;
 while (scanf("%d", &N) != EOF){
  int number[3001] = {0}, check[3001] = { 0 },temp,i;
  bool jolly = 1;

  scanf("%d", &number[0]);
  for ( i = 1; i<N; i++) {
   scanf("%d", &number[i]);
    temp = abs(number[i] - number[i - 1]);
   if (temp < 3001) check[temp]++;
  }

  for ( i = 1; i<N; i++)
   if (check[i] == 0 ) { jolly = 0; break; }

  if (jolly) printf("Jolly\n");
  else printf("Not jolly\n");
 }
 return 0;
}

留言

這個網誌中的熱門文章

Bundle Adjustment 光束平差法

Structure From Motion