#P10781. Maximum Flame Temperature
Maximum Flame Temperature
Maximum Flame Temperature
You are given a flame with an initial temperature of \(0\). There are \(n\) pieces of coal beside the flame, and each coal has an energy of \(k\) points. The temperature of the flame after burning \(i\) pieces of coal is defined by the recurrence:
\[ T_i = \begin{cases} 0 & \text{if } i = 0,\\[6pt] k + \dfrac{T_{i-1}}{i} & \text{if } i \ge 1. \end{cases} \]
Your task is to determine the highest temperature that the flame can reach. Note that you do not have to burn all \(n\) pieces of coal; the flame can achieve its maximum temperature after burning a number of coal pieces between \(0\) and \(n\).
Hint: Analyzing the recurrence, you will find that for \(n \ge 2\), the maximum is achieved when \(i = 2\) (or equivalently \(i=3\)).
inputFormat
The input consists of a single line containing two space-separated integers: \(n\) (the number of coal pieces) and \(k\) (the energy per coal piece).
\(0 \le n \le 10^5\), \(0 \le k \le 10^9\)
outputFormat
Output a single number representing the highest temperature the flame can reach. For \(n = 0\), output \(0\); for \(n = 1\), the temperature is \(k\); and for \(n \ge 2\), the maximum temperature is \(\frac{3}{2} k\).
sample
0 10
0