#CCBOTPBA0000030. Mô phỏng khoản tiền tăng trưởng (Integer Growth Until Threshold)
Mô phỏng khoản tiền tăng trưởng (Integer Growth Until Threshold)
Integer Growth Until Threshold
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Initial integer amount a is below b. At the end of every year update a=floor(a*(100+p)/100). Count the first year reaching b; return -1 if an update makes no progress below b.
Input
Three integers a b p.
Output
Minimum number of years or -1 if unreachable.
Subtasks
-
Subtask 1 (20%):
1 ≤ a < b ≤ 1000,0 ≤ p ≤ 100. -
Subtask 2 (30%):
1 ≤ a < b ≤ 10^6,0 ≤ p ≤ 100. -
Subtask 3 (50%):
1 ≤ a < b ≤ 10^9,0 ≤ p ≤ 100.
Examples
Example 1
Input:
100 110 10
Output:
1
Explanation: One update gives 110, reaching the threshold.
Example 2
Input:
1 2 1
Output:
-1
Explanation: The yearly update produces no increase.
Example 3
Input:
100 120 10
Output:
2
Explanation: The amounts after years one and two are 110 and 121.