POJ 2575
1 #include<iostream> 2 #include<set> 3 #include<stdio.h> 4 using namespace std; 5 6 int my_abs(int); 7 int main() 8 { 9 //freopen("acm.acm","r",stdin); 10 int num; 11 int i; 12 int * a; 13 set<int> coll; 14 while(cin>>num) 15 { 16 a = new int[num]; 17 for(i = 0; i < num; ++ i) 18 { 19 cin>>a[i]; 20 } 21 for(i = 0; i < num - 1; ++ i) 22 { 23 coll.insert(my_abs(a[i] - a[i+1])); 24 } 25 if((coll.size() == num - 1&&*coll.begin() == 1 && *coll.rbegin() == num - 1||num == 1)) 26 cout<<"Jolly"<<endl; 27 else 28 cout<<"Not jolly"<<endl; 29 coll.clear(); 30 delete[] a; 31 } 32 } 33 int my_abs(int num) 34 { 35 if(num >= 0) 36 return num; 37 else 38 return num * (-1); 39 40 }