-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsol.cpp
More file actions
executable file
·63 lines (47 loc) · 1.12 KB
/
Copy pathsol.cpp
File metadata and controls
executable file
·63 lines (47 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
57
58
59
60
61
62
63
#include <bits/stdc++.h>
using namespace std;
int DEGREES_PER_MARK = 360 / 40;
int turnFullCircle(int times)
{
return 360 * times;
}
int turnClockwiseToPosition(int ¤t, int target)
{
int dist = 0;
while (current != target)
{
--current;
if (current < 0)
current += 40;
dist++;
};
return dist * DEGREES_PER_MARK;
}
int turnCounterClockwiseToPosition(int ¤t, int target)
{
int dist = 0;
while (current != target)
{
current = (current + 1) % 40;
dist++;
};
return dist * DEGREES_PER_MARK;
}
int main()
{
int a, b, c, d;
while (cin >> a >> b >> c >> d)
{
if (a == 0 && b == 0 && c == 0 && d == 0)
break;
int degrees = 0;
int current_position = a;
degrees += turnFullCircle(2);
degrees += turnClockwiseToPosition(current_position, b);
degrees += turnFullCircle(1);
degrees += turnCounterClockwiseToPosition(current_position, c);
degrees += turnClockwiseToPosition(current_position, d);
cout << degrees << endl;
}
return 0;
}