-
Notifications
You must be signed in to change notification settings - Fork 0
/
00161.cpp
58 lines (48 loc) · 1.33 KB
/
00161.cpp
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
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
// ios_base::sync_with_stdio(false);
cin.tie(NULL);
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
ll n;
vector<ll> res;
while(cin >> n){
if(n==0 && res.size()==0){
ll d1, d2; cin >> d1 >> d2;
continue;
}
if(n==0){
ll Min = LLONG_MAX;
for(auto x: res){
Min = min(Min, x);
}
ll st = Min*2;
bool found = false;
for(ll i = st; i <= 18000; i++){
ll sum = 0;
for(auto x: res){
bool g = (i%(x*2) < x-5);
sum += g;
}
if(sum == res.size()){
ll temp = i;
ll h = temp/3600;
temp %= 3600;
ll m = temp/60;
temp %= 60;
ll s = temp;
printf("%02lld:%02lld:%02lld\n", h,m,s);
found = true;
break;
}
}
if(!found) cout << "Signals fail to synchronise in 5 hours\n";
res.clear();
continue;
}
res.push_back(n);
}
return 0;
}