문제

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

 

 풀이

t = int(input())

button_list = [300,60,10]
ans = []
count = 0

if t%10 != 0:
    print(-1)
else:
    for b in button_list:
        count = t//b
        ans.append(count)
        t = t%b
    print(ans[0],ans[1],ans[2],sep=' ')

간단한 문제인데 코드는 좀 조잡해보여서 간단하게 변경해보았다!

t = int(input())

button_list = [300,60,10]

if t%10 != 0:
    print(-1)
else:
    for b in button_list:
        print(t//b, end = ' ')
        t = t%b

+ Recent posts