C-log

💡2525번 본문

🧠Algorithm/Baekjoon💡

💡2525번

4:Bee 2023. 12. 6. 07:00
728x90

내가 작성한 코드는 아래와 같다.

H, M = map(int, input().split())
C = int(input())
 
MC = (M + int(C))
print(f"check : {MC}")
 
if 60 <= MC:
    H += (int(MC / 60))
    if 60 < MC:
        print("check")
        M = MC % 60
else:
    M = MC
if H == 24:
    H = 0

print(H, M)
# print(int(M / 60))

굉장히 정갈하지 못하다.

정답은 아래와 같다.

H, M = map(int, input().split())
timer = int(input())

H += timer // 60
M += timer % 60

if M >= 60:
    H += 1
    M -= 60
if H >= 24:
    H -= 24

print(H, M)
728x90

'🧠Algorithm > Baekjoon💡' 카테고리의 다른 글

💡15552번  (0) 2023.12.16
💡25314번  (0) 2023.12.16
💡2480번  (0) 2023.12.08
💡2884번  (0) 2023.12.06
💡1000번  (2) 2023.12.03
Comments