#P5515. Range of Power Sum Equivalence
Range of Power Sum Equivalence
Range of Power Sum Equivalence
Reimu obtained three real numbers \( n\), \( a\), \( b\) satisfying \(4\le n\le 5\) and \(5\le a,b\le 10\). She then computed
\[
f(n)=n^a+n^b,
\]
and the calculator displayed only the integer part of \( f(n) \), i.e. \(\lfloor n^a+n^b\rfloor\).
She wonders: if there exists a real number \( n'\) (with \( n'\ge0 \)) such that the calculator display of
\[
{n'}^a+{n'}^b
\]
is exactly the same as that of \( n^a+n^b\) (that is, their integer parts are equal), what is the range of all possible \( n' \)? Formally, if we define the set
\[
S=\{n'\ge0\;:\;\lfloor {n'}^a+{n'}^b\rfloor = \lfloor n^a+n^b\rfloor\},
\]
find the value of
\[
\Delta = \sup S - \inf S.
\]
Note that the function
\[
f(x)=x^a+x^b
\]
is strictly increasing for \( x\ge0 \). Therefore, if we let
\[
T = \lfloor n^a+n^b \rfloor,
\]
then the condition is equivalent to finding the unique numbers \( L \) and \( U \) satisfying
\[
f(L)=T \quad \text{and} \quad f(U)=T+1. \]
The answer for each query is \( s = U - L \).
If you are not sure how to compute \( n^k \), you may use the pow()
function from the cmath library, where pow(n,k)
computes \( n^k \) (in your language of choice).
Furthermore, there are \( T \) independent queries given in the input. For the \( i\)-th query you are given \( n_i, a_i, b_i \). Let the answer for the \( i\)-th query be \( s_i \); you are to output the sum
\[
S = \sum_{i=1}^{T} s_i.
\]
The answer is accepted if its absolute error does not exceed \(10^{-2}\).
Note on Input Generation:
To reduce input/output, the queries are generated via a pseudo‐random process. (See the provided code snippet in the statement.) For the case when a parameter op=1
, we have \( a=b \); otherwise, no special constraint is imposed.
inputFormat
The input begins with an integer \( T \) representing the number of queries. Each of the following \( T \) lines contains three real numbers \( n, a, b \) separated by spaces.
Constraints:
• \(4 \le n \le 5\)
• \(5 \le a, b \le 10\)
outputFormat
Output a single number: the sum of all ranges \( s_i \) for the queries, i.e. \(\sum_{i=1}^{T} s_i\). The answer is accepted if its absolute error is within \(10^{-2}\).
sample
1
4.0 5.0 5.0
0.00039063