Files
python/TangDou/LuoGuBook/P1152_1.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

23 lines
572 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include<bits/stdc++.h>
using namespace std;
const int N = 1010;
int a[N], c[N];
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d", &a[i]);//读入
for (int i = 1; i < n; i++) c[i] = abs(a[i] - a[i + 1]);//处理差
//按差值由小到大排序
sort(c + 1, c + n);
//检查一下缺少哪个数字缺少的条件是c[i]==i
for (int i = 1; i < n; i++) {
if (c[i] != i) {
printf("Not jolly");
return 0;
}
}
printf("Jolly");
return 0;
}