-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCaseOfFakeNumbers.cpp
More file actions
56 lines (43 loc) · 1.12 KB
/
CaseOfFakeNumbers.cpp
File metadata and controls
56 lines (43 loc) · 1.12 KB
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
49
50
51
52
53
54
55
56
#include <iostream>
#include <cstdio>
using namespace std;
bool isSame(int *initial, int *rotated, int size) {
for(int i = 0; i < size; i++) {
if(initial[i] != rotated[i]) {
return false;
}
}
return true;
}
int main() {
int n;
scanf("%d", &n);
int *initialGears = new int[n];
int *rotatedGears = new int[n];
for(int i = 0; i < n; i++) {
scanf("%d", &initialGears[i]);
rotatedGears[i] = initialGears[i];
}
bool result = true;
do {
result = true;
for(int i = 0; i < n; i++) {
if(i%2 == 0) {
rotatedGears[i]++;
if(rotatedGears[i] == n) {
rotatedGears[i] = 0;
}
}else {
rotatedGears[i]--;
if(rotatedGears[i] < 0) {
rotatedGears[i] = n - 1;
}
}
if( i != rotatedGears[i]) {
result = false;
}
}
}while(!isSame(initialGears, rotatedGears, n) && !result);
printf("%s\n", result ? "Yes" : "No");
return 0;
}