본문 바로가기

Programming [Python]/백준 알고리즘 솔루션

#14 백준 파이썬 [2839] 설탕 배달

#14 백준[2839] 설탕 배달

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




#14 [2839] Solution

-Easy Coding
order = int(input())

if order % 5 == 0:
print(order // 5)

elif order % 5 == 3:
print(order // 5 + 1)

elif order // 5 - 1 >= 0 and order - (5 * (order // 5 - 1)) == 6:
print((order // 5 - 1) + 2)

elif order // 5 - 1 >= 0 and order - (5 * (order // 5 - 1)) == 9:
print((order // 5 - 1) + 3)

elif order // 5 - 2 >= 0 and order - (5 * (order // 5 - 2)) == 12:
print((order // 5 - 2) + 4)

else:
print(-1)


-Short Coding

order = int(input())
three = 0
five = order//5
order %= 5

while five >=0:
if order % 3 ==0:
three = order//3
order %= 3;
break
five -= 1
order += 5
print(order==0 and (three + five) or -1)