<|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. The expected value is the sum of a geometric series: sum_{k=0..M-1} ((N-1)/N)^k.
   d. Compute this term by term: start with add=1, and for each winner multiply add by (N-1)/N.
   e. Print the accumulated sum with sufficient precision (e.g. fixed with 10 decimals).

   Time complexity is O(M) (summing the geometric series term by term), memory is O(1).

4. C++ implementation

```cpp
#include <bits/stdc++.h>

using namespace std;

template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& x) {
    return out << x.first << ' ' << x.second;
}

template<typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& x) {
    return in >> x.first >> x.second;
}

template<typename T>
istream& operator>>(istream& in, vector<T>& a) {
    for(auto& x: a) {
        in >> x;
    }
    return in;
};

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& a) {
    for(auto x: a) {
        out << x << ' ';
    }
    return out;
};

int n, m;

void read() { cin >> n >> m; }

void solve() {
    // Expected prizes = sum over winners of the probability that the winner
    // picks a box not yet opened. Before a winner picks, the probability that
    // any particular box is still sealed is ((n-1)/n) raised to the number of
    // previous picks, so the chance this winner opens a fresh box is that same
    // power. Summing the geometric series term by term: each term starts at 1
    // and is multiplied by (n-1)/n for the next winner.

    if(n == 1) {
        cout << "1.0\n";
        return;
    }

    double ans = 0, prob = 1.0 / n, add = 1.0;
    for(int pos = 0; pos < m; pos++) {
        ans += add;
        add *= (n - 1) * prob;
    }

    cout << fixed << setprecision(10) << ans << '\n';
}

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

    int T = 1;
    // cin >> T;
    for(int test = 1; test <= T; test++) {
        read();
        // cout << "Case #" << test << ": ";
        solve();
    }

    return 0;
}
```

5. Python implementation

```python
import sys
import math

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

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

    # Using the closed‐form expectation:
    # E = N * (1 - ((N-1)/N)^M)
    ratio = (n - 1) / n
    p_never = ratio**m
    expected = n * (1 - p_never)

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

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