-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.cpp
39 lines (35 loc) · 996 Bytes
/
main.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
// Author : Qi Zhang
// Date : 2018-12-11
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
while(getline(cin, s)) {
transform(s.begin(), s.end(), s.begin(), [](char& c) {return c == 'd' ? ' ' : c;});
istringstream is(s);
int a, b ,c, d;
is >> a >> b >> c >> d;
int se = a * 24 + b;
if(c > b) se ++;
if(c == b && d == 59) se ++;
int res = a * 3600 * 24 + b * 3600 + c * 60 + d - se;
string r;
a = res / (3600 * 24);
r = to_string(a) + "d";
b = (res - a * 3600 * 24) / 3600;
if(b / 10 == 0)
r += "0";
r += to_string(b);
r += " ";
c = (res - a * 3600 * 24 - b * 3600) / 60;
if(c / 10 == 0)
r += "0";
r += to_string(c);
r += " ";
d = res - a * 3600 * 24 - b * 3600 - c * 60;
if(d / 10 == 0)
r += "0";
r += to_string(d);
cout << r << endl;
}
}