| ||As a serious strategy-games player, you know how important it is to gather enough food for your army before any invasion. Because of this, you decided
to collect at least neededFood units of food for your soldiers.|
At the beginning, you have n workers to help you. In a single round, each of your workers gathers one unit of food. At the end of each round, you can trade some of your food for new workers. Hiring a single new worker costs price units of food. You can purchase any amount of new workers as long as you have the food to pay for it.
Return the minimum number of rounds you need to gather at least neededFood units of food.
|Parameters:||int, int, int|
|Method signature:||int gather(int neededFood, int n, int price)|
|(be sure your method is public)|
|-||neededFood, n and price will each be between 1 and 1000, inclusive.|
|Round 1: Gather 2 units of food. Hire a new worker.|
Round 2: Gather 3 units of food. Now you have 4 units.
Round 3: Gather 3 units of food. Now you have 7 units.
Round 4: Gather 3 units of food. Now you have 10 units - enough for your army.
|Round 1: Gather 4 units of food. Hire 4 new workers.|
Round 2: Gather 8 units of food. Hire 7 new workers.
Round 3: Gather 15 units of food. Now you have 16 units.
Round 4: Gather 15 units of food. Now you have 31 units - enough for your army.