백준/기초

[백준][if 문] 2884번 알람 시계

Snowboarder 2022. 2. 22. 13:47

문제접근

  • 시간을 어떻게 활용을 할 것인가
  • 내풀이는 시간과 분을 나누어서 사용
  • 다른사람풀이는 시간 + 분을해서 -45 해서 다시 시간 분으로 초기화
  • 숏코딩

문제풀이

내풀이

hour,minute = map(int, input().split())

if minute > 44:
    print(hour, minute-45)
elif minute <= 44 and hour >= 1:
    print(hour-1, minute+15)
else:
    print(23, minute+15)

다른사람풀이

a,b=map(int,input().split());x=a*60+b-45;print(x//60%24,x%60)

숏코딩

a,b=map(int,input().split())
print((a-(b<45))%24,(b-45)%60)