forked from Mohammed-Shoaib/Coding-Problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB0093.cpp
More file actions
45 lines (40 loc) · 718 Bytes
/
B0093.cpp
File metadata and controls
45 lines (40 loc) · 718 Bytes
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 Code: EVENT
#include <iostream>
#include <string>
#include <cmath>
#include <unordered_map>
using namespace std;
unordered_map<string, int> days({
{"saturday", 0},
{"sunday", 1},
{"monday", 2},
{"tuesday", 3},
{"wednesday", 4},
{"thursday", 5},
{"friday", 6}
});
string eventDuration(string S, string E, int L, int R) {
int d = days[E] - days[S] + 1;
if(d < 0)
d += 7;
if (L > d) {
int div = ceil((L - d) / 7.0);
d += 7*div;
}
if (R < d)
return "impossible";
else if (R < d + 7)
return to_string(d);
else
return "many";
}
int main() {
int T, L, R;
string S, E;
cin >> T;
while (T--) {
cin >> S >> E >> L >> R;
cout << eventDuration(S, E, L, R) << endl;
}
return 0;
}