Game of Gnomes
Time limit1sMemory limit512 MB
Split n gnomes into at most m groups so that the enemy's bolts, each killing k gnomes from one group per turn, let you deal the most total damage.
Problem
The enemy and their massive army are approaching your fortress, and the only defense is a legion of guardian gnomes. Winning is hopeless, so the goal is to deal as much damage to the enemy as possible.
You have gnomes. Before the battle, you divide them into at most non-empty groups. The battle proceeds in turns. Each turn, the gnomes attack and deal one unit of damage for each living gnome. Then the enemy throws a lightning bolt at one of the groups. The bolt kills gnomes in that group, or all of them if the group has fewer than living gnomes. The battle ends when all gnomes are dead. The enemy always throws the bolts optimally, so that the total damage is minimized.
What is the maximum total damage you can deal to the enemy if you divide the gnomes into groups optimally?
Input
A single line contains three integers , , and (, ).
Output
Print the maximum amount of damage you can cause to the enemy.