Another Goose Goose Duck Problem
InterviewTime limit1sMemory limit1024 MB
Choose an integer cooldown a in [l, r] and find the minimum time to kill k geese that arrive every b seconds.
Problem
Teacher Rice likes playing the famous game 'Goose Goose Duck'. In the game, he plays a duck, and his goal is to kill geese. Each time he kills a goose, he must wait seconds for his kill skill to cool down. Since Teacher Rice's role is the Serial Killer, the waiting time depends on which type of goose he kills. As a skilled killer, he can set the waiting time to any integer in .
Teacher Rice meets a goose every seconds. When he meets a goose and his kill skill is ready, he can choose to kill it. Otherwise, the goose runs away immediately and he cannot kill it.
Teacher Rice wants to know the minimum time he needs to kill geese.
Input
One line contains four integers , , , (, ).
Output
Output one integer, the time Teacher Rice needs to kill geese.