1133A. Middle of the Contest

A. Middle of the Contest
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
Polycarp is going to participate in the contest. It starts at h1:m1 and ends at h2:m2. It is guaranteed that the contest lasts an even number of minutes (i.e. m1%2=m2%2, where x%y is x modulo 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 to 11:00 then the answer is 10:30, if the contest lasts from 11:10 to 11:12 then the answer is 11:11.

Input
The first line of the input contains two integers h1 and m1 in the format hh:mm.

The second line of the input contains two integers h2 and m2 in the same format (hh:mm).

It is guaranteed that 0≤h1,h2≤23 and 0≤m1,m2≤59.

It is guaranteed that the contest lasts an even number of minutes (i.e. m1%2=m2%2, where x%y is x modulo 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 h3 and m3 (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
inputCopy
10:00
11:00
outputCopy
10:30
inputCopy
11:10
11:12
outputCopy
11:11
inputCopy
01:02
03:02
outputCopy
02:02

#include<iostream>
using namespace std;
int main()
{
	char a[5],b[5];
	cin>>a>>b;
	int m,n;
	m=600*(a[0]-'0')+60*(a[1]-'0')+10*(a[3]-'0')+1*(a[4]-'0');
	n=600*(b[0]-'0')+60*(b[1]-'0')+10*(b[3]-'0')+1*(b[4]-'0');
	//cout<<m<<" "<<n;
	m=(m+n)/2;
	//cout<<m;
	int hour,min;
	hour=m/60;
	min=m%60;
	if(hour<10)
	{
		cout<<"0"<<hour<<":";
	}
	else
	{
		cout<<hour<<":";
	}
	if(min<10)
	{
		cout<<"0"<<min;
	}
	else
	{
		cout<<min;
	}
 } 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值