0
点赞
收藏
分享

微信扫一扫

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

343d85639154 2022-06-27 阅读 77

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

A - Middle of the Contest(签到题)Codeforces Round #544 (Div. 3)_#define
测试样例

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代码

/*

*
*/
#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;
}


举报

相关推荐

0 条评论