poj 2575 Jolly Jumpers

//没有认真读题,WA了两次,因为他们的差值的顺序不一定需要按升序或者降序排列的!具体可以用下面的数据进行测试! 
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;

int dif[3000];

int main(){
	int n;
	while(cin >> n){
		memset(dif,0,sizeof(dif));
		int pre,current;
		cin >> pre;
		int i;
		for(i = 1; i < n; i++){
			cin >> current;
			int abs_dif = abs(current - pre);
			dif[abs_dif] = 1;
			pre = current; 	
		}
		
		for(i = 1; i < n; i++){
			if(dif[i] == 0)
				break;
		}

		if(i == n)
			cout << "Jolly" << endl;
		else
			cout << "Not jolly" << endl;
	}
}
/*
4 6 3 2 0
1 2
2 2 2
3 1 2 3
3 3 2 1
4 4 4 4 4
*/

你可能感兴趣的:(测试)