P28237 [洛谷] [MtOI2019] Reimu's Calculator
提高-
题目描述

Background

Note: This background is adapted from a real event where disangan233 bought a calculator before the high school entrance exam.

Hakurei Reimu successfully retrieved the offerings stolen by Yakumo Yukari through the gap. After that, she and Yorigami Shion went to Kourindou to shop.

Reimu wanted to buy a calculator to manage the offerings of the shrine, but due to the high prices at Kourindou, she decided to order a Casio calculator online through Kawashiro Nitori's Network (KNN).

Unexpectedly, the Casio calculator Reimu received from KNN was a counterfeit, which could only display the integer part (i.e., floor function).

Reimu was distressed because this calculator might cause significant errors. Therefore, she wants you, who has a computer (referring to a shikigami from the outside world), to help her solve a problem.

Problem Description

Reimu has obtained three real numbers \( n \), \( a \), and \( b \) ( \( 4 \le n \le 5, 5 \le a, b \le 10 \) ). She successfully calculated \( n^a + n^b \) and obtained a result that only shows the integer part.

Reimu wants to know the range of \( n' \) (where \( n' \ge 0 \)) such that the result of \( {n'}^a + {n'}^b \) displayed on the calculator is exactly the same as the result of \( n^a + n^b \). She needs the difference between the maximum and minimum values of \( n' \).

If you do not know how to calculate \( n^k \), please use the pow() function from the cmath library, where pow(n, k) gives the result of \( n^k \).


To increase the difficulty of this problem, Reimu sets up \( T \) queries for you. To reduce your input and output volume to some extent, we use the following code to generate queries (code from Kawashiro Nitori):

namespace Mker
{
//  Powered By Kawashiro_Nitori
//  Made In Gensokyo, Nihon
    #define uint unsigned int
    uint sd;int op;
    inline void init() {scanf("%u %d", &sd, &op);}
    inline uint uint_rand()
    {
        sd ^= sd << 13;
        sd ^= sd >> 7;
        sd ^= sd << 11;
        return sd;
    }
    inline double get_n()
    {
        double x = (double) (uint_rand() % 100000) / 100000;
        return x + 4;
    }
    inline double get_k()
    {
        double x = (double) (uint_rand() % 100000) / 100000;
        return (x + 1) * 5;
    }
    inline void read(double &n,double &a, double &b)
    {
        n = get_n(); a = get_k();
        if (op) b = a;
        else b = get_k(); 
    }
}

After calling the Mker::init() function, the \( i \)-th call to Mker::read(n, a, b) will give you \( n_i \), \( a_i \), and \( b_i \) for the \( i \)-th query.

To reduce your output volume, let the answer for the \( i \)-th query be \( s_i \). You only need to output \( \sum_{i=1}^{T} s_i \). If your answer is within an absolute error of \( 10^{-2} \) from the standard answer, your answer is considered correct.

The data generation uses a high-precision algorithm with a time complexity significantly worse than ordinary algorithms to ensure precision. The data guarantees that the error for a single query is less than \( 10^{-10} \), so the SPJ range for this problem is fully sufficient for the correct solution.


To help you better solve the problem, here is the explanation for \( op \):

  • When \( op = 1 \), \( a = b \); otherwise, no special restrictions.

Input Format

The input consists of a single line containing three positive integers \( T \), \( seed \), and \( op \), as described in the problem.

Output Format

Output a single line containing the answer as described in the problem.

Sample Input and Output

Input Example #1

500 233 0

Output Example #1

0.00503

Input Example #2

10000 3141592653 0

Output Example #2

0.10166

Input Example #3

50000 1314159 0

Output Example #3

0.50722

Input Example #4

50000 1314159 1

Output Example #4

1.51676

Input Example #5

1000000 5201314 0

Output Example #5

10.30487

Notes

Subtasks

QQ图片20190707214000.png

Problem Source

MtOI2019 League (MtOI2019) T2

Problem Author: disangan233

Problem Tester: suwakow

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
500 233 0
样例输出
0.00503