#K33282. Expected Widget Production
Expected Widget Production
Expected Widget Production
You are given n machines. Each machine is characterized by three parameters:
- p: the probability that the machine breaks down during the day.
- a: the minimum number of widgets it can produce.
- b: the maximum number of widgets it can produce.
If a machine does not break down (which happens with probability \(1-p\)), its production is uniformly distributed between \(a\) and \(b\). In such a case, the expected production of that machine is \(\frac{a+b}{2}\). If \(a = b\), then the machine always produces exactly \(a\) widgets. Your task is to compute the expected total number of widgets produced by all machines in a day.
All answers should be computed with an accuracy up to 6 decimal places.
inputFormat
The input is read from standard input (stdin) and consists of the following:
- A single integer \(n\) representing the number of machines.
- \(n\) lines follow. Each line contains three values separated by spaces:
- A floating-point number \(p\) (the probability of breakdown).
- An integer \(a\) (the minimum production).
- An integer \(b\) (the maximum production, with \(a \leq b\)).
outputFormat
Output a single floating-point number representing the expected total production of widgets, printed to standard output (stdout). The number should be formatted to 6 decimal places.
## sample1
0.0 1 5
3.000000
</p>