https://www.acmicpc.net/problem/2884


풀이
H, M = map(int, input().split())

if M < 45:
  if H == 0:
    H = 23
    M += 15
  else:
    H -= 1
    M += 15
else:
  M -= 45

print(H,M)

 

> -15%60 = 45 같이 음수롤 mod 연산하면 양수가 나온다(나머지는 항상 0보다 크거나 같아야 한다)

위의 연산적 특징을 이용하면 코드를 더욱 간결하게 줄일 수 있다.

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

if M-45 < 0:
    H = (H-1)%24
    M = (M-45)%60
else:
    M = (M-45)%60

print(H,M)

+ Recent posts