Math problems 6-8 grade
Agent Johnny English met another enemy in front of him, whom he had to kill. To make sure that his clumsiness would not interfere with this, he decided to shoot him exactly n shots from his pistol. His pistol has a magazine for m rounds, which, of course, is not initially loaded.
Johnny English can fully reload his pistol in a seconds or add one cartridge to the chamber in b seconds. One shot takes exactly one second. Help him to find the minimum amount of time Agent Johnny English can make exactly n shots. Of course, he cannot fire an empty pistol and cannot put a new cartridge into an already full magazine.
The first line contains four integers n, m, a и b (1 ≤ n, m, a, b ≤
10^4) - the number of shots to be fired, the size of the pistol magazine, the time it takes to fully reload the magazine and the time to load one cartridge.
Print one number - the minimum time it will take for the agent to fire exactly n shots.
During the test, Johnny had to fully load the pistol once, fire twice, then insert one cartridge and fire.
3 2 1 1