'commit'
This commit is contained in:
23
TangDou/LuoGuBook/P1152_1.cpp
Normal file
23
TangDou/LuoGuBook/P1152_1.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user