<|instruction|>
Solve the below problem. The solution should start with an abridged problem statement. Then key observations. Then full solution based on the observations. Then C++ and Python implementations with comments.

495. Kids and Prizes
Time limit per test: 0.25 second(s)
Memory limit: 262144 kilobytes
input: standard
output: standard



ICPC (International Cardboard Producing Company) is in the business of producing cardboard boxes. Recently the company organized a contest for kids for the best design of a cardboard box and selected M winners. There are N prizes for the winners, each one carefully packed in a cardboard box (made by the ICPC, of course). The awarding process will be as follows:
All the boxes with prizes will be stored in a separate room.
The winners will enter the room, one at a time.
Each winner selects one of the boxes.
The selected box is opened by a representative of the organizing committee.
If the box contains a prize, the winner takes it.
If the box is empty (because the same box has already been selected by one or more previous winners), the winner will instead get a certificate printed on a sheet of excellent cardboard (made by ICPC, of course).
Whether there is a prize or not, the box is re-sealed and returned to the room.
The management of the company would like to know how many prizes will be given by the above process. It is assumed that each winner picks a box at random and that all boxes are equally likely to be picked. Compute the mathematical expectation of the number of prizes given (the certificates are not counted as prizes, of course).

Input
The first and only line of the input file contains the values of N and M ().

Output
The first and only line of the output file should contain a single real number: the expected number of prizes given out. The answer is accepted as correct if either the absolute or the relative error is less than or equal to 10-9.

Example(s)
sample input
sample output
5 7
3.951424

sample input
sample output
4 3
2.3125

<|response|>
1. Abridged problem statement  
   Given N sealed boxes (each initially contains exactly one prize) and M winners who each select one box uniformly at random with replacement. A winner receives a prize only if they choose a box that has never been chosen before; otherwise they get a certificate. After each selection the box is resealed. Compute the expected total number of prizes awarded.

2. Key observations  
   - Let Xi be the indicator random variable that box i is chosen at least once in the M draws.  
   - The total number of prizes awarded S = X1 + X2 + … + XN.  
   - By linearity of expectation, E[S] = E[X1] + E[X2] + … + E[XN] = N · E[Xi] (all Xi are identically distributed).  
   - For a fixed box i, the probability it is never chosen in M draws is  
        P(Xi = 0) = ((N−1)/N)^M.  
     Hence P(Xi = 1) = 1 − ((N−1)/N)^M, so  
        E[Xi] = 1 − ((N−1)/N)^M.  
   - Therefore the answer is  
        E[S] = N × (1 − ((N−1)/N)^M).  
   - Edge case: if N = 1, then there is only one box and one prize will certainly be awarded (answer = 1.0).

3. Full solution approach  
   a. Read integers N and M.  
   b. If N == 1, print “1.0” and exit.  
   c. Compute the ratio r = (N−1)/N as a double.  
   d. Compute r^M using the standard library power function (or by fast exponentiation).  
   e. Compute expected = N * (1 − r^M).  
   f. Print expected with sufficient precision (e.g. fixed with 10 decimals).  

   Time complexity is O(1) (a few arithmetic operations and one power), memory is O(1).

4. C++ implementation with detailed comments  

```cpp
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    long long N, M;
    cin >> N >> M;

    // Edge case: only one box => always exactly one prize
    if (N == 1) {
        cout << "1.0\n";
        return 0;
    }

    // Compute ratio r = (N-1)/N
    double r = double(N - 1) / double(N);

    // Compute r^M
    double r_pow_m = pow(r, M);

    // Expected number of distinct boxes chosen = N * (1 - r^M)
    double expected = N * (1.0 - r_pow_m);

    // Output with high precision (absolute or relative error <= 1e-9)
    cout << fixed << setprecision(10) << expected << "\n";

    return 0;
}
```

5. Python implementation with detailed comments  

```python
import sys
import math

def main():
    data = sys.stdin.read().strip().split()
    n, m = map(int, data)

    # Edge case: one box => always one prize
    if n == 1:
        print("1.0")
        return

    # Compute ratio r = (n-1)/n
    r = (n - 1) / n

    # Compute r^m
    r_pow_m = r**m  # Python's float exponentiation

    # Expected number of prizes
    expected = n * (1 - r_pow_m)

    # Print with sufficient precision
    print(f"{expected:.10f}")

if __name__ == "__main__":
    main()
```