매일코테

백준 7단계 no.1

공주맛밤 2022. 7. 24. 11:26

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();
        int n;

        if ((c - b) <= 0) {
            n = -1;
        } else {
            n = (a / (c - b)) +1;
        }

        System.out.println(n);
    }
}

-> 틀린 이유: 나눗셈을 할 땐 항상 0을 조심하자

728x90
반응형