#HLPRSRCH. Help a researcher
Help a researcher
A scientist was doing a research on some kinds of bacteria. He found that the kinds, he examined, take T unit of time to grow (be mature) enough in order to can reproduce.
Also he found that each type reproduces with a constant rate which is N new bacteria every F unit of time, (where F=T).
Task
write a program that reads L (number of bacteria (at the beginning of the experiment)), M (number of mature bacteria of them), T (time of each to get mature which is also the time needed for reproducing N new bacteria), N (rate of reproducing per T unit of time) and Z (period elapsed by the experiment).
Calculate the number of bacteria after Z unit of time. Regardless of life-span.
Constraints
- 1 ≤ L ≤ 5 number of bacteria (at the beginning of the experiment).
- 0 ≤ M ≤ L number of mature bacteria.
- 1 ≤ T ≤ 5 time of each to get mature which is also the time needed for reproducing N new bacteria.
- 1 ≤ N ≤ 50 rate of reproducing per T unit of time.
- 1 ≤ Z/T ≤ 4,300 period elapsed by the experiment.
Note: Z is always divisible by T.
Input
- L (number of bacteria (at the beginning of the experiment))
- M (number of mature bacteria of them)
- T (time of each to get mature which is also the time needed for reproducing N new bacteria)
- N (rate of reproducing per T unit of time)
- Z (period elapsed by the experiment)
Output
- the number of bacteria after Z unit of time. Regardless of life-span.
Example
Input: 3 2 3 1 3</p>Output: 5
Input 2 0 1 1 100 Output: 1146295688027634168202
Explanation for Test Case 1
The experiment begins with 2 mature bacteria and one immature bacterium. For each of the mature bacteria reproduces after 3 units of time. Then th total becomes 4 - as each one got a new one (2*2). But for the immature bacterium after 3 units of time, it only become mature. After all of that the experiment finishes with 5 bacteria.