Polycarp is going to participate in the contest. It starts at
h
1
:
m
1
h1:m1
and ends at
h
2
:
m
2
h2:m2
. It is guaranteed that the contest lasts an even number of minutes (i.e.
m
1
%2=
m
2
%2
m1%2=m2%2
, where
x%y
x%y
is
x
x
modulo
y
y
). 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:00
10:00
to
11:00
11:00
then the answer is
10:30
10:30
, if the contest lasts from
11:10
11:10
to
11:12
11:12
then the answer is
11:11
11:11
.
Input
The first line of the input contains two integers
h
1
h1
and
m
1
m1
in the format hh:mm.
The second line of the input contains two integers
h
2
h2
and
m
2
m2
in the same format (hh:mm).
It is guaranteed that
0≤
h
1
,
h
2
≤23
0≤h1,h2≤23
and
0≤
m
1
,
m
2
≤59
0≤m1,m2≤59
.
It is guaranteed that the contest lasts an even number of minutes (i.e.
m
1
%2=
m
2
%2
m1%2=m2%2
, where
x%y
x%y
is
x
x
modulo
y
y
). 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
h
3
h3
and
m
3
m3
(
0≤
h
3
≤23,0≤
m
3
≤59
0≤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
问题链接: http://codeforces.com/contest/1133/problem/A
问题简述: 给定两个时间,要求求两段的平均时间。
问题分析: 先将差值求出来转换成分钟数,再加到第一个时间上,该进位的进位即可(就这么个简单的操作的题就搞了我贼久
AC通过的C++语言程序如下:
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<bitset>
#include<utility>
#include<functional>
#include<iomanip>
#include<sstream>
#include<ctime>
using namespace std;
const int N=1005;
int main()
{
string a,b;
cin>>a;
int u1=(a[0]-'0')*10+(a[1]-'0');
int v1=(a[3]-'0')*10+(a[4]-'0');
cin>>b;
int u2=(b[0]-'0')*10+(b[1]-'0');
int v2=(b[3]-'0')*10+(b[4]-'0');
int sz=u2-u1;
int fz=v2-v1;
int sj=sz*60+fz;
sj/=2;
int flag=0,cc=sj%60;
while(sj>=60)
{
sj-=60;
flag++;
}
if(v1+cc>=60)
{
v1=(v1+cc)-60;
u1++;
}
else v1+=cc;
u1+=flag;
if(u1<10&&v1<10)
cout<<0<<u1<<":"<<0<<v1<<endl;
else if(u1<10&&v1>=10)
cout<<0<<u1<<":"<<v1<<endl;
else if(u1>=10&&v1<10)
cout<<u1<<":"<<0<<v1<<endl;
else cout<<u1<<":"<<v1<<endl;
return 0;
}