#K3001. Expected Growth of Plants
Expected Growth of Plants
Expected Growth of Plants
You are given an initial number of plants (N). In each time step, every plant produces (k) seeds, and each seed has a probability of (\frac{p}{100}) to grow into a new plant. This process is repeated for (n) time steps. The expected number of plants (E_n) is computed with the recurrence:
[ E_0 = N, ]
and for each (i = 1, 2, \ldots, n):
[ E_i = E_{i-1} \times k \times \frac{p}{100}. ]
Your task is to calculate (E_n) for each test case and output the result. Note that if (n = 0), the expected number of plants remains (N).
inputFormat
The input is read from standard input (stdin). The first line contains an integer (T), the number of test cases. Each of the following (T) lines contains four space-separated numbers:
(N) (k) (p) (n)
where:
- (N) is the initial number of plants,
- (k) is the number of seeds produced by each plant,
- (p) is the probability percentage (an integer between 0 and 100) that a seed will grow into a new plant,
- (n) is the number of time steps.
outputFormat
For each test case, print the expected number of plants after (n) time steps on a separate line to standard output (stdout).## sample
1
2 3 50 1
3.0
</p>