CS/Algorithm

[Python : 1408] 24 (시간 차이 구하는 문제)

yujindonut 2022. 2. 3. 13:15
728x90

www.acmicpc.net/problem/1408

 

1408번: 24

도현이는 Counter Terror Unit (CTU)에서 일하는 특수요원이다. 도현이는 모든 사건을 정확하게 24시간이 되는 순간 해결하는 것으로 유명하다. 도현이는 1시간 만에 범인을 잡을 수 있어도 잡지 않는

www.acmicpc.net

문제가 잘 이해가 안가서 참고했음

 

#문제가 이해가 잘안감
h, m, s = map(int, input().split(':')) 
h1, m1, s1 = map(int, input().split(':')) 
curtime = h*3600 + m*60 + s 
totime = h1*3600 + m1*60 + s1 
if h > h1: 
    totime += 24*3600 
time = totime - curtime 
a = str(time//3600) 
b = str((time % 3600)//60) 
c = str((time % 3600) % 60) 
if (time//3600)//10 == 0: 
    a = "0" + str(time//3600) 
if ((time % 3600)//60)//10 == 0: 
    b = "0" + str((time % 3600)//60) 
if ((time % 3600) % 60) // 10 == 0: 
    c = "0" + str((time % 3600) % 60) 
print(a+":"+b+":"+c)
728x90