본문 바로가기
Java/알고리즘

[Java] 백준 1712번: 손익분기점

by EricJeong 2019. 8. 21.

 

 

 

import java.util.Scanner;
public class Main {
	public static long bep(long A, long B, long C) {
		long answer = 0;
		long sell = C-B;
		
		if(sell <= 0)
			return -1;
		
		while(answer*sell <= A) {
			answer++;
		}
		return answer;
	}
	
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long A = in.nextLong();
		long B = in.nextLong();
		long C = in.nextLong();
		
		System.out.println(bep(A,B,C));
	}
}

댓글