땅 위에 달팽이가 있다. 이 달팽이는 높이가 V미터인 나무 막대를 올라갈 것이다.
달팽이는 낮에 A미터 올라갈 수 있다. 하지만, 밤에 잠을 자는 동안 B미터 미끄러진다. 또, 정상에 올라간 후에는 미끄러지지 않는다.
달팽이가 나무 막대를 모두 올라가려면, 며칠이 걸리는지 구하는 프로그램을 작성하시오.
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int up = sc.nextInt();
int down = sc.nextInt();
int size = sc.nextInt();
int date = (size - down) / (up - down);
// 나머지가 있을 경우 (잔여 블럭이 있을 경우)
if ((size - down) % (up - down) != 0) {
date++;
}
System.out.println(date);
}
}
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class Main {
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
String[] UDS = br.readLine().split(" ");
double U = Integer.parseInt(UDS[0]); // 낮동안 올라가는 길이
double D = Integer.parseInt(UDS[1]); // 밤동안 미끄러지는 길이
double S = Integer.parseInt(UDS[2]); // 나무 막대의 길이
int X = (int) Math.ceil((S - D) / (U - D)); // 올라가는 데 걸리는 일 수
bw.write(String.valueOf(X));
br.close();
bw.flush();
bw.close();
}
}