-
Notifications
You must be signed in to change notification settings - Fork 2
/
10683.cpp
41 lines (35 loc) · 1.02 KB
/
10683.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
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
char decimalTime[8];
unsigned long long hours, minutes, seconds, fractions;
while(cin >> decimalTime)
{
for(int i = 0; i < 8; i++)
decimalTime[i] -= '0';
hours = 10*decimalTime[0]+decimalTime[1];
minutes = 10*decimalTime[2]+decimalTime[3];
seconds = 10*decimalTime[4]+decimalTime[5];
fractions = 10*decimalTime[6]+decimalTime[7];
//Convert time to hundreths of a second
minutes += 60 * hours;
seconds += 60 * minutes;
fractions += 100 * seconds;
//Convert to decadary time
fractions *= 125;
fractions /= 108;
//Convert to decadary hours, minutes, and seconds
hours = fractions / (100 * 100 * 100);
fractions -= hours*100*100*100;
minutes = fractions / (100 * 100);
fractions -= minutes * 100*100;
seconds = fractions / 100;
fractions -= seconds * 100;
cout << hours << setw(2) << setfill('0') << minutes
<< setw(2) << setfill('0') << seconds << setw(2)
<< setfill('0') << fractions << endl;
}
return 0;
}