A. Middle of the Contest
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
10:00
11:00
output
10:30
input
11:10 11:12
output
11:11
input
01:02 03:02
output
02:02
#include <stdio.h>
using namespace std;
int main()
{
int h1, h2, m1, m2;
scanf("%d:%d%d:%d",&h1,&m1,&h2,&m2);
int h=h1+h2;///总的小时
int m=m1+m2;///总的分钟
if (m>=60)
m-=60,h+=1;///分钟超过1小时,就进1
if (h%2==0)
printf("%02d:%02d\n",h/2,m/2);
else
{///总小时不能被二整除且总分钟小于60
h-=1;
m+=60;///多出的一小时给分钟
printf("%02d:%02d\n",h/2,m/2);
}///注意格式
return 0;
}