#P14027. 【MX-X20-T1】「FAOI-R7」加训加训

【MX-X20-T1】「FAOI-R7」加训加训

Description

Little C is a hard worker who trains every day.

Little C starts with an initial ability value aa and aims to reach a target ability value bb. Both aa and bb are non-negative integers, and it is guaranteed that a<ba < b. There is a positive integer kk. Each day, Little C can choose one of the following two training methods:

  • Normal training: After training, Little C's ability value becomes a+ka + k.
  • Train harder: After training, Little C's ability value becomes a×ka \times k.

Little C wants to know: what is the minimum number of days required to make his ability value greater than or equal to bb?

Input Format

Only one line containing two non-negative integers aa, bb and one positive integer kk, representing the initial ability value, the target ability value, and the parameter for ability growth, respectively.

Output Format

Output one line containing a positive integer, which is the answer.

2 4 2
1
1 100 3
4
0 5 2
3
1 3 8
1

Hint

Explanation #1

Choose normal training. After training, the ability value becomes 2+2=42 + 2 = 4, achieving the goal in one day.

Explanation #2

The training plan is as follows:

  • On the first day, choose normal training. After training, the ability value becomes 1+3=41 + 3 = 4.
  • On the second day, choose train harder. After training, the ability value becomes 4×3=124 \times 3 = 12.
  • On the third day, choose train harder. After training, the ability value becomes 12×3=3612 \times 3 = 36.
  • On the fourth day, choose train harder. After training, the ability value becomes 36×3=10836 \times 3 = 108.

The goal is achieved in four days.

Explanation #3

The training plan is as follows:

  • On the first day, choose normal training. After training, the ability value becomes 0+2=20 + 2 = 2.
  • On the second day, choose normal training. After training, the ability value becomes 2+2=42 + 2 = 4.
  • On the third day, choose normal training. After training, the ability value becomes 4+2=64 + 2 = 6.

The goal is achieved in three days.

Data Range

For 30%30\% of the data, 2a<b1032 \le a < b \le 10^3, k2k \ge 2.

For another 20%20\% of the data, k=1k = 1.

For all data, 0a<b1060 \le a < b \le 10^6, 1k1061 \le k \le 10^6.


Translated by DeepSeek V3.1