Difficulty: Medium

Pre-requisites: Mathematics

Problem link:

Contest problem link

Practice problem link


An amoeba of generation i divides itself into Ai amoebas and takes X days to divide. Find the number of amoebas left after M days.


We are starting with one amoeba. After X days we would have sum = 1+A1 amoebas, after X more days we will have sum = sum+A2 amoebas. The process is to be continued M-1 times to compute the number of amoebas left post M days.

Problem setter’s solution: SOLUTION