-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay1.cpp
More file actions
91 lines (81 loc) · 1.99 KB
/
Day1.cpp
File metadata and controls
91 lines (81 loc) · 1.99 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include <bits/stdc++.h>
#define int long long
#define allr(x) (x).rbegin(), (x).rend()
#define all(x) (x).begin(), (x).end()
#define ld long double
#define INF (int)(1e18)
#define MOD 1000000007
using namespace std;
void Part1() {
int num = 50, cnt = 0;
string s;
while (cin >> s && s != "?") {
if (s[0] == 'R') {
string x = s.substr(1);
int rot = 0;
if (!x.empty())
rot = stoll(x);
num += rot;
num %= 100;
if (num == 0)cnt++;
} else if (s[0] == 'L') {
string x = s.substr(1);
int rot = 0;
if (!x.empty())
rot = stoll(x);
num -= rot;
num %= 100;
num += 100;
num %= 100;
if (num == 0)cnt++;
}
}
// ? at the condition to break the loop add it to input
cout << cnt << "\n";
}
void Part2() {
int num = 50, cnt = 0;
string s;
while (cin >> s && s != "?") {
if (s[0] == 'R') {
string x = s.substr(1);
int rot = 0;
if (!x.empty())
rot = stoll(x);
while (rot--) {
num++;
if (num > 99) {
num %= 100;
}
if (num == 0)cnt++;
}
} else if (s[0] == 'L') {
string x = s.substr(1);
int rot = 0;
if (!x.empty())
rot = stoll(x);
while (rot--) {
num--;
if (num < 0) {
num += 100;
num %= 100;
}
if (num == 0)cnt++;
}
}
}
cout << cnt << "\n";
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// freopen("promote.in","r",stdin);
// freopen("promote.out","w",stdout);
int tests = 1;
// cin >> tests;
while (tests--) {
//Part1();
//Part2();
}
}