[백준] JAVA/기본 수학 1
[백준] JAVA 2869: 달팽이는 올라가고 싶다
코딩하는곰곰
2021. 12. 12. 14:38
https://www.acmicpc.net/problem/2869
2869번: 달팽이는 올라가고 싶다
첫째 줄에 세 정수 A, B, V가 공백으로 구분되어서 주어진다. (1 ≤ B < A ≤ V ≤ 1,000,000,000)
www.acmicpc.net
Solution:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine()," ");
int up = Integer.parseInt(st.nextToken());
int down = Integer.parseInt(st.nextToken());
int height = Integer.parseInt(st.nextToken());
if ((height-down)%(up-down)==0) {
System.out.print((height-down)/(up-down));
}
else {
System.out.print((height-down)/(up-down)+1);
}
br.close();
}
}