Baekjoonアルゴリズム | 2869番問題: 登るカタツムリ

出典

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

問題

Baekjoon Online Judgeの2869番問題、登るカタツムリを解きます。

入力

正確な入力形式と制約は元の問題文に従います。

出力

問題で求められる答えを出力します。

サンプル入力 1

2 1 5

サンプル出力 1

4

サンプル入力 2

5 1 6

サンプル出力 2

2

サンプル入力 3

2 1 5

サンプル出力 3

4

サンプル入力 4

100 99 1000000000

サンプル出力 4

999999901

アルゴリズム分類

  • 数学

解説

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);
        }
    }
}