-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAnEasyProblem.cpp
67 lines (53 loc) · 1019 Bytes
/
AnEasyProblem.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
59
60
61
62
63
64
65
66
67
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Author - Kevin Mathew
// Birla Institute of Technology, Mesra
ll h, m, x;
string s, s1, s2;
void te(){
cin >> s;
cin >> x;
s1 = s.substr(0, 2);
s2 = s.substr(3, 2);
h = stoll(s1);
m = stoll(s2);
// cout << h << " " << m << "\n";
ll th = h;
ll tm = m;
ll i = 0;
for(ll i=0;i<10000;i++){
ll f = h / 10;
ll s = h % 10;
ll thi = m / 10;
ll fo = m % 10;
// cout << f << " " << s << " " << thi << " " << fo << "\n";
// cout << (f + s + thi + fo) << "\n";
if(((f + s + thi + fo) % x) == 0){
cout << i << "\n";
return;
}
m++;
if(m == 60){
m = m % 60;
h++;
if(h == 24){
h = h % 24;
}
}
if(h == th && m == tm){
cout << -1 << "\n";
return;
}
}
}
int main()
{
// freopen("input.txt", "r", stdin); //Comment
// freopen("output.txt", "w", stdout); //this out.
ios::sync_with_stdio(false); //Not
cin.tie(NULL); //this.
cout.tie(0); //or this.
te();
return 0;
}