[백준] 2884번 : 알람 시계

letsbebrave·2022년 1월 3일
0

codingtest

목록 보기
17/146

문제

개념

map(변환 함수, 순환가능 데이터)

map(int, a)

  • 리스트의 요소를 지정된 함수로 처리함
  • 보통 여러 개의 데이터를 한 번에 다른 형태로 바꾸기 위해 사용
    문자열을 int형으로 변환
a = '1 2'
a = list(map(int, a.split()) #[1, 2] int형

cf. map 함수를 이용한 문제
https://velog.io/@letsbebrave/%EB%B0%B1%EC%A4%80-1330%EB%B2%88-%EB%8B%A8%EC%96%B4-%EA%B3%B5%EB%B6%80

풀이

# time = [None] * 2

# time[0], time[1] = input().split()

# H = int(time[0])
# M = int(time[1])

H, M = map(int,input().split()) #위의 긴 코드를 이렇게 한 줄로 바꿀 수 있다!

M = H*60 + M - 45

H = M // 60
if  H == -1 :
    H = 23
M = M % 60

print(f'{H} {M}')
profile
그게, 할 수 있다고 믿어야 해

0개의 댓글