Skip to content

savingforretirement

bradendubois edited this page Nov 8, 2021 · 8 revisions

Saving For Retirement

ID: savingforretirement

Difficulty: 1.9

CPU Time: 1 second

Memory: 1024 MB

Solution

Since Bob saves Bs every year, he saves (Br - B) * Bs in total, making Alice's target that exact amount, plus 1. To get this, we can take the ceiling of this goal divided by how much she saves every year, As; this is the number of years Alice must save, so we can output this plus A.

Clone this wiki locally