-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path542.cpp
More file actions
73 lines (66 loc) · 1.11 KB
/
Copy path542.cpp
File metadata and controls
73 lines (66 loc) · 1.11 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
#include <iostream>
#include <cstring>
using namespace std;
int times[105];
int cycles[105];
int main() {
while (1) {
int n = 0;
int s = 2147483647;
int temp;
memset(times, 0, sizeof(int) * 105);
memset(cycles, 0, sizeof(int) * 105);
while (cin >> temp) {
if (temp == 0) {
break;
}
else {
cycles[n++] = temp;
s = s < temp ? s : temp;
}
}
if (cycles[0] == 0) {
break;
}
bool done = false;
while (s <= 18000 && !done) {
done = true;
for (int i=0;i<n;i++) {
while (times[i] + cycles[i] - 5 <= s) {
times[i] += 2 * cycles[i];
}
if (!(times[i] <= s && s < times[i]+cycles[i]-5)) {
s = times[i] - 1;
done = false;
break;
}
}
s++;
}
if (!done) {
cout << "Signals fail to synchronise in 5 hours\n";
}
else {
s--;
int hh = s / 3600;
int mm = s % 3600 / 60;
int ss = s % 60;
if (hh < 10) {
cout << '0';
}
cout << hh;
cout << ':';
if (mm < 10) {
cout << '0';
}
cout << mm;
cout << ':';
if (ss < 10) {
cout << '0';
}
cout << ss;
cout << endl;
}
}
return 0;
}