spoj#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 progam that reads L (number of bacteria (at the begining 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 begining of the experiment)
1 ≤ 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 begining 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
Output:
5
The experiment begins with 2 mature bacteria and one unmature 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 unmature bacterium after 3 units of time, it only become mature.
After all of that the experiment finishes with 5 bacteria.Input
2
0
1
1
100
Output:
1146295688027634168202