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 984 (Div. 3) 題解
- Codeforces Round 962 (Div. 3) 題解
- Codeforces Round 946 (Div. 3) 題解
- Codeforces Round #615 (Div. 3) (題解)
- Codeforces Round #690 (Div. 3)
- Codeforces Round 954 (Div. 3)
- Codeforces Round 943 (Div. 3)
- Codeforces Round 974 (Div. 3)
- Codeforces Round 981 (Div. 3)
- Codeforces Round 962(Div. 3)
- Codeforces Round 962 (Div. 3)
- Codeforces Round 957 (Div. 3)
- Codeforces Round 950 (Div. 3)
- Codeforces Round 966 (Div. 3)
- Codeforces Round 946 (Div. 3)
- Codeforces Round 981 (Div. 3) 題解(A-E)
- Codeforces Round 984 (Div. 3) 題解總結
- Codeforces Round 957 (Div. 3) A-G 題解
- Codeforces Round 970 (Div. 3)A~F
- Codeforces Round 981 (Div. 3)(A~E)
- Codeforces Round 933 (Div. 3)
- Codeforces Round 938 (Div. 3) E
- Codeforces Round 916 (Div. 3)
- Codeforces Round 966 (Div. 3) VP
- Codeforces Round #216 (Div. 2) B. Valera and Contest
- Codeforces Round 984 (Div. 3)題解記錄(A~F)
- Codeforces Round 962 (Div. 3) 補題記錄(A~G)
- Codeforces Round 962 (Div. 3) D. Fun 題解
- Codeforces Round 988 (Div. 3)題解記錄(A~F)
- Codeforces Round 988 (Div. 3) 補題記錄(A~G)
- Codeforces Round 970 (Div. 3) ABCDEFGH
- Codeforces Round 950 (Div. 3)個人題解(A~F1)
- Codeforces Round 976 (Div. 2) 題解
- Codeforces Round 983 (Div. 2) 題解
- Codeforces Round #956 (Div. 2)題解
- Codeforces Round 951 (Div. 2) 題解
- Codeforces Round 965 (Div. 2) 題解