#B3856. Seconds Elapsed in Coconut Milk Land
Seconds Elapsed in Coconut Milk Land
Seconds Elapsed in Coconut Milk Land
In Coconut Milk Land, a day consists of \(n\) hours. The \(i\)-th hour (with \(0 \le i < n\)) has \(i+1\) minutes, and the \(j\)-th minute of the \(i\)-th hour (with \(0 \le j \le i\)) contains \(10j+1\) seconds. Note that hours, minutes, and seconds are all counted from 0.
Given two timestamps \(t_1 = A:B:C\) and \(t_2 = E:F:G\), where \(t_1\) is \(A\) hour \(B\) minute \(C\) second and \(t_2\) is \(E\) hour \(F\) minute \(G\) second, and it is guaranteed that \(t_2\) is not earlier than \(t_1\) and the time difference is less than a day, compute the total number of seconds that have elapsed from \(t_1\) to \(t_2\).
To compute the absolute seconds for a given time \(T = A:B:C\), consider that the total seconds elapsed from the start of the day up to \(T\) is given by:
[ S(T) = \sum_{i=0}^{A-1} (i+1)(5i+1) + \sum_{j=0}^{B-1} (10j+1) + C, ]
where the sum \(\sum_{i=0}^{A-1} (i+1)(5i+1)\) computes the seconds in all complete hours before hour \(A\) (since the total seconds in the \(i\)-th hour is \((i+1)(5i+1)\)), and \(\sum_{j=0}^{B-1} (10j+1)\) computes the seconds in all complete minutes in the current hour \(A\). The answer is \(S(t_2) - S(t_1)\).
inputFormat
The input consists of two lines. The first line contains the starting timestamp \(t_1 = A:B:C\) and the second line contains the ending timestamp \(t_2 = E:F:G\). In each timestamp, the hour, minute, and second values are separated by a colon.
outputFormat
Output a single integer representing the total number of seconds elapsed from \(t_1\) to \(t_2\).
sample
0:0:0
0:0:0
0