TopCoder problem "FlatCatsBreeding" used in TCHS10 Round 2 (Division I Level One)



Problem Statement

    A flat cat is a fictional Martian animal known for being an extremely affectionate pet and also for being able to replicate itself promptly given favorable conditions. The cat replicates itself when it is D, 2*D, 3*D, ... days old, and each time, it creates K new kittens. You have been presented with a newborn flat cat. Return the number of days after which you will have at least T cats, assuming that cats don't die.
 

Definition

    
Class:FlatCatsBreeding
Method:days
Parameters:int, int, int
Returns:int
Method signature:int days(int D, int K, int T)
(be sure your method is public)
    
 

Constraints

-D will be between 1 and 100, inclusive.
-K will be between 1 and 10, inclusive.
-T will be between 1 and 1000000, inclusive.
 

Examples

0)
    
4
3
1
Returns: 0
You have one cat as soon as you are presented with it, so you don't have to wait until it replicates.
1)
    
4
3
4
Returns: 4
After 4 days, the first cat produces 3 kittens, so you will have a total of 4 cats.
2)
    
4
3
9
Returns: 8
After 4 days, you'll have four cats. After 4 more days, each of those cats will produce 3 kittens, for a total of 16 cats. Note that you don't need to have exactly T cats, but at least T.
3)
    
4
3
1000000
Returns: 40
4)
    
91
6
10433
Returns: 455
5)
    
9
7
17079
Returns: 45

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=10790

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=14225&pm=10790

Writer:

Nickolas

Testers:

PabloGilberto , ivan_metelsky , StevieT

Problem categories:

Brute Force