IT_Baekjoon 단계별로 풀어보기/수학 1,2
2939_Python // 설탕 배달
Pangaea_T
2020. 1. 29. 19:09
Python
i = int(input())
j = i
c = 0
while(True) :
if(j%3 == 0 and int(j/3)< 5) :
c = c+int(j/3)
break
else :
if(j>=5) :
c += 1
j -= 5
else :
c = -1
break
if(c == -1) :
print(c)
else :
if(i%5 == 0) :
print(int(i/5))
elif(c > int(i/3)) :
print(int(i/3))
else :
print(c)
while문의 첫 if문 조건중 int(j/3) < 5 가 있는 이유는 3과 5의 공배수인 15의 경우 5로 나누는게 효율적이기 때문에 3의 몫이 5를 넘는 경우를 조건에 넣은 것 입니다.
===
어려웠네요