#39132: c++解題攻略超簡單


ianlin766909@gmail.com (ian lin)

學校 : 不指定學校
編號 : 245102
來源 : [1.163.104.115]
最後登入時間 :
2024-07-28 16:43:13
d097. 10038 - Jolly Jumpers -- UVa10038 | From: [36.224.4.86] | 發表日期 : 2024-01-19 21:00

#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