poj2575

    技术2024-11-02  26

    #include <stdio.h>#include <stdlib.h>

    int main(){

     int n; int i,flag; int *a; int *diff;

     while(scanf("%d",&n) != EOF) {  flag = 1;  a = (int *)malloc((n+1)*sizeof(int));  diff = (int *)malloc(n*sizeof(int));

      for(i=1; i<=n-1;i++)   diff[i] = 0;

      for(i=1;i<=n;i++)  {   scanf("%d",&a[i]);  }

      for(i=1;i<=n-1 ; i++)  {   diff[abs(a[i+1]-a[i])] = 1;  }

      for(i=1;i<=n-1;i++)   if(diff[i] == 0)   {    flag = 0;    break;   }

      if(flag ==1)   printf("Jolly/n");  else   printf("Not jolly/n"); }

     free(a); free(diff); return 0;}

    最新回复(0)