zoj 1879 || poj 2575 Jolly Jumpers(水~)

意思就是,输入一个数n,然后输入n个数,两两之差的绝对值是不是从1到n-1。。。把1到n-1出现一遍就OK了。刚开始还以为得按顺序出现。。。查了查那个take on。。。米有这含义。。。这个博客纯粹当作业本了。。。好水的都发到这。。。就这样吧~~~~~

 

 

 

#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> int diff[3002]; int main(void) { int n,x,y,check,i; while(scanf("%d",&n)!=EOF) { check = 1; memset(diff,0,sizeof(diff)); if( n==1 ) { scanf("%d",&x); printf("Jolly/n"); continue; } scanf("%d",&x); for(i=1; i<n; i++) { scanf("%d",&y); diff[abs(x-y)] = 1; x = y; } for(i=1; i<n; i++) if(diff[i] == 0) check = 0; if( check ) printf("Jolly/n"); else printf("Not jolly/n"); } system("pause"); return 0; }

你可能感兴趣的:(System,作业)