백준 1712번 자바 : 손익분기점

Rena·2022년 3월 2일
0

알고리즘 문제풀이

목록 보기
1/45
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        if(C <= B){
            System.out.println("-1");
        } else {
            System.out.println(A/(C-B)+1);
        }
        sc.close();
    }
}

A/(C-B)가 소수점으로 떨어질 수 있는거 아닌가????
했지만... int 나누기 int = int

이래서 자바 기초가 중요합니다 ㅎㅎ

profile
일을 사랑하고 싶은 개발자

0개의 댓글