BOJ

백준 파이썬 1712 손익분기점

Coding_SJ 2020. 3. 16. 16:55

 

 

 

 

 

1
2
3
4
5
6
7
8
9
10
a,b,c = map(int,input().split())
 
if (c-b) > 0:
    print(int(a/(c-b)+1))
 
elif c==b:
    print(-1)    
 
elif (c-b) < 0:
    print(-1)
cs

 

분모가 0이 될 수 있는 식을 쓰면 런타임에러가 뜬다.

그러니까 if문 시작전에 num = a/(c-b) 이런식으로 선언하면 안된다.