F |
Probability
Calculation Input: Standard Input Output: Standard Output |
Boeing and Airbus are the two Major Commercial plane-producing companies. The planes produced by Boeing have two engines and the planes produced by Airbus have four engines. But this does not guarantee that Airbus planes are safer than those of Boeing. Both Boeing and Airbus try to hype up their products as much as possible but in this problem will not try to cover this issue.
There are some interesting probability problems with 2-engine and 4-engine planes. Many people say that for a plane to remain on air successfully, at least 50% of its engines must remain operative. In this problem we will assume it to be true. So if a plane has 5 engines then at least 3 of them needs to be operative to ensure a successful flight. If all the engines have equal probability p of remaining operative throughout the flight and failure of engines is independent of one another then we can use binomial theorem to calculate the probability of successful flight. For example the probability that a 5-engine plane will make a successful flight is:
, here
So in general,
Another function CF is defined as:
In the planes of present time we generally don’t see more than four engines. But some scientists are planning to make planes with thousands of very small engines. The reasons are the following:
In this problem your job is help the new scientists by finding out the value of CF(m), given the value of m and p. They claim that these values will be very helpful for their research.
The input file contains around 12 sets of inputs. The description of each set is given below:
The first line of each set contains a floating-point number p (0≤p≤1) and an integer Q (0 <Q ≤ 2000). Here p is the probability that an engine will not fail during flight and Q is the total number of query. Each of the next Q lines contains an integer, which denotes a possible value of m (0<m<50001).
Input is terminated by a case where the value of Q is zero.
For each set of input Q+1 lines of output. The first line contains the serial of the set. Each of the next Q lines contains one floating-point number which denotes the value of CF(m). These floating-point numbers should have 8 digits after the decimal point. Look at the output for sample input for details. Errors less than max(2*10-8, 2*10-6 %) will be ignored.
0.9 3 10 11 12 0.1 3 100 20 30 0.4 0 |
Case 1: 9.84427253 10.84397682 11.84392664 Case 2: 0.40625000 0.40624417 0.40624997 |
Problemsetter: Shahriar Manzoor, Special Thanks:
Arifuzzaman Arif