A - Middle of the Contest(签到题)Codeforces Round #544 (Div. 3)

原题链接: https://codeforces.com/problemset/problem/1133/A

在这里插入图片描述
测试样例

Input
10:00
11:00
Output
10:30
Input
11:10
11:12
Output
11:11
Input
01:02
03:02
Output
02:02

题意: 给你起始时间和终止时间,让你求出中点时间段。保证起始和终止的时间差为偶数。

解题思路: 相加直接求总时长再除以2即可。注意输出,总时长除60得时,对60取余得分,输出要注意前导0。

AC代码

/*
*邮箱:unique_powerhouse@qq.com
*blog:https://me.csdn.net/hzf0701
*注:文章若有任何问题请私信我或评论区留言,谢谢支持。
*
*/
#include<bits/stdc++.h>//POJ不支持

#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=a;i>=n;i--)

using namespace std;

const int inf=0x3f3f3f3f;//无穷大。
const int maxn=1e5;//限定值。
typedef long long ll;

int h1,h2,m1,m2;
int main(){
	char op;
	while(cin>>h1>>op>>m1){
		cin>>h2>>op>>m2;
		int times=((h2+h1)*60+(m2+m1))/2;
		if(times/60<10){
			cout<<"0"<<times/60;
		}
		else{
			cout<<times/60;
		}
		cout<<":";
		if(times%60<10){
			cout<<"0"<<times%60;
		}
		else{
			cout<<times%60;
		}
		cout<<endl;
	}
	return 0;
}
posted @ 2022-03-26 16:49  unique_pursuit  阅读(29)  评论(0)    收藏  举报