zoj 1879 Jolly Jumpers

来源:互联网 发布:mac电脑如何更新系统 编辑:程序博客网 时间:2024/06/07 08:57

sequence of n > 0 integers is called a jolly jumper if the absolute values of the difference between successive elements take on all the values 1 through n-1.

 

水题。。

#include<stdio.h>#include<math.h>int main(){int a[3005],i,x,y,flag,n,d;while(scanf("%d",&n)!=EOF){for(i=0;i<3005;i++)a[i]=0;scanf("%d",&x);flag=0;for(i=1;i<n;i++){scanf("%d",&y);d=abs(y-x);if(d>=n||d==0||a[d])flag=1;elsea[d]=1;x=y;}if(flag)printf("Not jolly\n");elseprintf("Jolly\n");}return 0;}


 

原创粉丝点击