[SWEA] 1976 시각덧셈

김은서·2021년 9월 15일
0

SWEA

목록 보기
33/47

풀이

  1. 시와 분 따로 받기
  2. 더한 값이 60이 넘을 경우 시에 1을 더해주고 분은 60 빼주기
  3. 12시간을 기준으로 하기에 12를 넘으면 12 빼주기

Python Code

T = int(input())
for tc in range(1, T+1):
    h1, m1, h2, m2 = map(int, input().split())
    h3 = h1 + h2
    m3 = m1 + m2
    if m3 >= 60:
        h3 += 1
        m3 -= 60
    if h3 > 12:
        h3 -= 12
    print('#{} {} {}'.format(tc, h3, m3))
profile
Gracelog

0개의 댓글