object Solution { def main(args: Array[String]) { val Array(a, b, t) = io.StdIn.readLine.split(" ").map(_.toInt) val total = growth(a, b, t, 1) % (Math.pow(10, 9) + 7) toInt println(total) } @annotation.tailrec def growth(a: Int, b: Int, t: Int, cells: Double): Double = t match { case 0 => cells case _ => growth(a, b, t - 1, 0.5 * a * cells + 0.5 * b * cells) } }