题目:
Consider a special type of animal known as an Ewwok that reproduces following the rules below:
An Ewwok dies six months after it is born. That is, if an Ewwok is born in month 0, it will die in month 6.
An Ewwok gives birth to two Ewwoks every two months until it dies. That is, if an Ewwok is born in month 0, it will reproduce in months 2 and 4. It does not reproduce in month 6 or beyond.
In each month, among all the Ewwoks that have been alive for exactly three months, there is one that dies. That is, if there are n (n > 0) Ewwoks that are born in month 0, one of them will die in month 3.
Given an integer initial representing the number of Ewwoks born in month 0, and an integer m representing a month, your task in this question is to write a program that calculates and returns the number of Ewwoks alive in month m.
- 阅读剩余部分 -
最近回复