Codeforces Round #544 (Div. 3) A.Middle of the Contest

链接:https://codeforces.com/contest/1133/problem/A

题意:

给两个时间点,求中间时间点。

思路:

数学

代码:

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;

int main()
{
    int h1, h2, m1, m2;
    scanf("%d:%d", &h1, &m1);
    scanf("%d:%d", &h2, &m2);
    int h = h1 + h2;
    int m = m1 + m2;
    if (m >= 60)
        m -= 60, h += 1;
    if (h % 2 == 0)
    {
        printf("%02d:%02d\n", h / 2, m / 2);
    }
    else
    {
        h -= 1;
        m += 60;
        printf("%02d:%02d\n", h / 2, m / 2);
    }

    return 0;
}

  

posted @ 2019-03-09 11:45  YDDDD  阅读(157)  评论(0编辑  收藏  举报