Baekjoon Algorithm | Problem 2869: Climbing Snail

Source

https://www.acmicpc.net/problem/2869

Problem

Solve Baekjoon Online Judge problem 2869, Climbing Snail.

Input

Follow the input format and constraints given in the original problem statement.

Output

Print the answer required by the problem.

Sample Input 1

2 1 5

Sample Output 1

4

Sample Input 2

5 1 6

Sample Output 2

2

Sample Input 3

2 1 5

Sample Output 3

4

Sample Input 4

100 99 1000000000

Sample Output 4

999999901

Algorithm Classification

  • Math

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 {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            StringTokenizer input = new StringTokenizer(br.readLine(), " ");

            double a = Integer.parseInt(input.nextToken());
            double b = Integer.parseInt(input.nextToken());
            double v = Integer.parseInt(input.nextToken());

            System.out.println((int) Math.ceil((v - a) / (a - b)) + 1);
        }
    }
}