## 문제
BOJ 2884 알람 시계
## 풀이
45분 일찍 알람 설정하기.
시간은 H시 M분으로. 24시간 표현을 사용한다.
불필요한 0은 사용하지 않기.
분에서 45를 빼면 되는데
분이 45보다 작다면 시간에서 1을 빼고 분에 60을 더한뒤에 빼면 되고.
시간이 1보다 작다면,(0시인 상태) +24 -1 = 23시로 만들면 된다.
## 코드
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tmp_input = input().split() | |
H = int(tmp_input[0]) | |
M = int(tmp_input[1]) | |
if M >= 45: | |
M = M - 45 | |
else: | |
if H >= 1: | |
H = H - 1 | |
M = M + 60 - 45 | |
else: | |
H = H + 24 - 1 | |
M = M + 60 - 45 | |
print(str(H) + ' ' + str(M)) |
00 45 일경우.
처음 case나눌때 등호 빼먹어서 틀렸었음.
0 댓글