매일 Algorithm

신재원·2023년 1월 21일
0

Algorithm

목록 보기
13/243

백준 1712번 손익 분기점

import java.util.Scanner;

public class Solution {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();

        // 상품 가격보다 가변 비용이 높으면 -1 반환
        if(b >= c ){
            System.out.println("-1");
        }else{
            // 하드코딩을 줄여야 하지만, 변수 저장시 by zero 예외발생
            System.out.println((a/(c-b))+1);
        }


    }
}

0개의 댓글