[백준] #1712 손익 분기점 python

2022. 12. 23. 16:10

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

 

1712번: 손익분기점

월드전자는 노트북을 제조하고 판매하는 회사이다. 노트북 판매 대수에 상관없이 매년 임대료, 재산세, 보험료, 급여 등 A만원의 고정 비용이 들며, 한 대의 노트북을 생산하는 데에는 재료비와

www.acmicpc.net

시간 복잡도를 고려해야한다.

 

그러나 꼼수를 사용한 것 같다.. 정확한 풀이를 알아보자.

 

default_cost, factory_cost, product_cost = map(int, input().split())

cnt = 0
if factory_cost >= product_cost:
    print(-1)
else:
    while True:
        cnt += 10000
        if default_cost + factory_cost * cnt < product_cost * cnt:
            break
    while True:
        cnt -= 1
        if default_cost + factory_cost * cnt >= product_cost * cnt:
            break
    print(cnt+1)

BELATED ARTICLES

more