Algorithm/백준

[백준] 전자레인지 - 파이썬

potato_pizza 2024. 6. 20. 16:39
728x90

전자레인지

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

 

문제

코드

# 전자레인지

T = int(input())

A, B, C = 300, 60, 10

result = [0, 0, 0]

while T >= 10:
    if T >= A:
        result[0] += T // A
        T %= A
    elif T < A and T >= B:
        result[1] += T // B
        T %= B
    elif T < B and T >= C:
        result[2] += T // C
        T %= C

if T != 0:
    print(-1)
else:
    print(f'{result[0]} {result[1]} {result[2]}')

 

  • 더 간결한 풀이
t=int(input())

if t % 10 !=0:
    print(-1)
else:
    a,b,c=0,0,0
    a=t//300
    b=(t % 300) // 60
    c=(t % 60) // 10
    print(a,b,c)
728x90
반응형