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;
}
相關文章
- Codeforces Round #713 (Div. 3)AB題
- Codeforces Round #615 (Div. 3) (題解)
- Codeforces Round #690 (Div. 3)
- Codeforces Round 943 (Div. 3)
- Codeforces Round #216 (Div. 2) B. Valera and Contest
- Codeforces Round 933 (Div. 3)
- Codeforces Round 938 (Div. 3) E
- 4.4Codeforces Round 935 (Div. 3)
- Codeforces Round 940 (Div. 2) and CodeCraft-23 (contest id: 1957)Raft
- Codeforces Round #681 (Div. 2)E題解
- Codeforces Round 932 (Div. 2) DE 題解
- Codeforces Round 943 (Div. 3)(C-G1)
- Codeforces Round #639 (Div. 2)
- Codeforces Round #541 (Div. 2)
- Codeforces Round #682 (Div. 2)
- Codeforces Round #678 (Div. 2)
- Codeforces Round #747 (Div. 2)
- Codeforces Round #673 (Div. 2)
- Codeforces Round #672 (Div. 2)
- Codeforces Round #448 (Div. 2) A
- Codeforces Round #217 (Div. 2)
- Codeforces Round #256 (Div. 2)
- Codeforces Round #259 (Div. 2)
- Codeforces Round #257 (Div. 2)
- Codeforces Round #258 (Div. 2)
- Codeforces Round #171 (Div. 2)
- Codeforces Round #173 (Div. 2)
- Codeforces Round 932 (Div. 2)
- Codeforces Round 934 (Div. 2)
- Codeforces Round 940 (Div. 2)
- Codeforces Round 859 (Div. 4)
- Codeforces Round 934 (Div. 1)
- Educational Codeforces Round 93 (Rated for Div. 2)題解
- Codeforces Round #665 (Div. 2)A-C題解
- Codeforces Round #673 (Div. 2)(A-D)題解
- Codeforces Round #439 (Div. 2) A-C題解
- Codeforces Round #360 (Div. 2) D 數學題
- Codeforces Round #Pi (Div. 2) (ABCD題解)