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


shawn2000100 (東華財金)

學校 : 國立東華大學
編號 : 57300
來源 : [27.53.168.5]
最後登入時間 :
2021-09-19 19:53:19
d097. 10038 - Jolly Jumpers -- UVa10038 | From: [36.225.78.133] | 發表日期 : 2017-12-09 22:29

#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;
}

 
ZeroJudge Forum