-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJollyJumper.cpp
48 lines (44 loc) · 777 Bytes
/
JollyJumper.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
-by Imakshat47
Joly Jumper
*/
#include <iostream>
using namespace std;
int jollyJumper()
{
int n;
scanf("%d", &n);
int A[n];
for (int i = 1; i < n - 1; ++i)
scanf("%d", A[i]);
int ndiff = 0, diff = abs(A[0] - A[1]), pval = 0;
for (int i = 1; i < n - 1; ++i)
{
if (i == 1)
{
pval = ndiff - diff;
if (abs(pval) != 1)
return 0;
}
if (i > 1)
{
if (diff - ndiff != pval)
return 0;
}
diff = ndiff;
}
return 1;
}
int main()
{
int t;
scanf("%d", &t);
while (t--)
{
if (jollyJumper())
printf("Joly");
else
printf("Not Joly");
}
return 0;
}