[백준] 1712번(ZeroDivisionError)

·2022년 11월 9일

백준 문제풀이

목록 보기
18/159

백준 1712번


최종 제출 코드

import math

a, b, c = map(float, input().split())

# ZeroDivisionError 발생
if c-b==0:
  print(-1)
else:
  x = a/(c-b)
  if x < 0:
    print(-1)
  else:
    print(math.floor(x+1))

수정 전 코드

import math

a, b, c = map(float, input().split())

x = a/(c-b)

if x < 0:
  print(-1)
else:
  print(math.floor(x+1))
  • c-b0일 경우 ZeroDivisionError 발생
profile
백엔드 개발자가 되고 싶어요(22.8.15~)

0개의 댓글