[颗秒!!! ]直接干拉
2026-08-08 20:45:38
发布于:陕西
2阅读
0回复
0点赞
#include<bits/stdc++.h>//万能头
#include<vector>//动态数组
#include<cmath>//要用abs
using namespace std;
int main(){
ios_base::sync_with_stdio(false);//万金油
int n;
cin >> n;
vector<int> a(n);
for(int i = 0; i < n; i++){
cin >> a[i];
}//症常开头
if(n == 1){
cout << "Jolly" << '\n';
return 0;
}//判断是否只有一个元素,是就直接Jolly
vector<bool> seen(n, false);
for(int i = 1; i < n; i++){
int diff = abs(a[i] - a[i - 1]);
if(diff >= 1 && diff <= n - 1){
seen[diff] = true;
}//标记河里数值
}
bool isjolly = true;
for(int i = 1; i <= n - 1; i++){
if(!seen[i]){
isjolly = false;
break;
}
}//检查是否1到n-1都出现过
if(isjolly){
cout << "Jolly" << '\n';
}else{
cout << "Not jolly" << '\n';
}//输出
return 0;
}
这里空空如也







有帮助,赞一个