-
Notifications
You must be signed in to change notification settings - Fork 33
/
10038.cpp
executable file
·45 lines (39 loc) · 934 Bytes
/
10038.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
/* Problem: Jolly Jumpers UVa 10038
Programmer: Md. Mahmud Ahsan
Compiled: Visual C++ 6.0
Date: 29-09-04
*/
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
int main(){
int input; // for test case
int i;
int last, next, result; // temporary used for set the places
bool flag; // check if jolly or not jolly
while (cin >> input){
// each time place will automatically initialized to zero
vector <bool> place(3005);
flag = true;
cin >> last;
// i = 1 as first input take before it
for (i = 1; i < input; i++){
cin >> next;
result = abs(last - next);
place[result] = true;
last = next;
}
// main condition successive elements take place
for (i = 1; i < input; i++)
if (!place[i]){
flag = false;
break;
}
if (flag)
cout << "Jolly" << endl;
else
cout << "Not jolly" << endl;
}
return 0;
}