#13111: C++簡易參考解答


shawn2000100 (東華財金)


#include <iostream>
using namespace std;

int main(){
int n, input[3007] = {0};
while(cin >> n){
for(int i = 0; i < n; ++i)
cin >> input[i];

bool diff[n] = {false};
for(int i = 1; i < n; ++i){
int idx = abs(input[i - 1] - input[i] );
if(idx < n)
diff[idx] = true;
}

bool jolly = true;
for(int i = 1; i <= n - 1; ++i){
if(!diff[i]){
jolly = false;
break;
}
}

cout << (jolly ? "Jolly" : "Not jolly") << endl;

}

return 0;
}