time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Polycarp is going to participate in the contest. It starts at h1:m1h1:m1 and ends at h2:m2h2:m2. It is guaranteed that the contest lasts an even number of minutes (i.e. m1%2=m2%2m1%2=m2%2, where x%yx%y is xx modulo yy). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes.
Polycarp wants to know the time of the midpoint of the contest. For example, if the contest lasts from 10:0010:00 to 11:0011:00 then the answer is 10:3010:30, if the contest lasts from 11:1011:10 to 11:1211:12 then the answer is 11:1111:11.
Input
The first line of the input contains two integers h1h1 and m1m1 in the format hh:mm.
The second line of the input contains two integers h2h2 and m2m2 in the same format (hh:mm).
It is guaranteed that 0≤h1,h2≤230≤h1,h2≤23 and 0≤m1,m2≤590≤m1,m2≤59.
It is guaranteed that the contest lasts an even number of minutes (i.e. m1%2=m2%2m1%2=m2%2, where x%yx%y is xx modulo yy). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes.
Output
Print two integers h3h3 and m3m3 (0≤h3≤23,0≤m3≤590≤h3≤23,0≤m3≤59) corresponding to the midpoint of the contest in the format hh:mm. Print each number as exactly two digits (prepend a number with leading zero if needed), separate them with ':'.
Examples
input
Copy
10:00 11:00
output
Copy
10:30
input
Copy
11:10 11:12
output
Copy
11:11
input
Copy
01:02 03:02
output
Copy
02:02
解题说明:水题,求中两个时间的中间时间。
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int h1, m1, h2, m2;
int main()
{
scanf("%d:%d%d:%d", &h1, &m1, &h2, &m2);
int t = ((h1 + h2) * 60 + m1 + m2) / 2;
printf("%02d:%02d\n", t / 60, t % 60);
return 0;
}