HLPRSRCH - Help a researcher

no tags 

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 ≤ ML 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

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.


hide comments
:D: 2010-11-25 23:11:55

There is only ONE test case per file.

Rofael Emil: Yes.

Last edit: 2010-12-11 22:13:55
RuPp$: 2010-11-25 15:28:16

when shall i stop taking input??

Rofael Emil: After reading only 5 integers (L, M, T, N and Z)

each one is in a line.

Last edit: 2010-11-25 15:19:07
RuPp$: 2010-11-25 15:28:16

Can anyone add more testcases?? I am getting wrong answer :(

Rofael Emil: another sample test-case is added

Last edit: 2010-11-30 08:21:35
Rofael Emil: 2010-11-25 15:28:16

@Anton Lunyov: Thanks a lot
It's now modified

Anton Lunyov: 2010-11-25 15:28:16

What are the real constraints for L and N?

Mohamed Maher: 2010-11-25 15:28:16

plz write the resource


Added by:Rofael Emil
Date:2010-11-07
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All