题解:P1152 欢乐的跳
题目传送门
题意
给定 Jolly,否则输出 Not jolly。
思路
显然,我们可以用 Jolly,并结束程序。否则输出 Not jolly。
代码
#include <bits/stdc++.h>
using namespace std;
int n, a[1010], b[1010];
int main()
{
scanf("%d", &n);
for (int i = 1; i <= n; i++)
scanf("%d", &a[i]);
for (int i = 1; i < n; i++)
b[i] = abs(a[i + 1] - a[i]);
sort(b + 1, b + n);
for (int i = 1; i < n; i++)
if (b[i] != i)
{
printf("Not jolly");
return 0;
}
printf("Jolly");
return 0;
}
题解来之不易,且看且珍惜。给个赞再走吧。
题目传送门