Time limit
2s
Memory limit
128 MB
A new album by has just been released. Kangto wants to listen to the whole album exactly once from the beginning.
The album contains N songs, and every song lasts L seconds. Between two adjacent songs there is a 5-second quiet interval when no song is playing.
Let time 0 be the moment Kangto starts listening to the first song. His phone also starts ringing at time 0, and then rings once every D seconds. Each ring lasts for 1 second.
Because Kangto listens at a very high volume, he cannot hear the ringtone while a song is playing. If a ring starts exactly when a song starts, he cannot hear it. If a ring ends exactly when a song ends, he also cannot hear it.
After all songs in the album have finished, Kangto can hear the ringtone.
Find the earliest time when Kangto can hear his phone ring.
The first line contains three integers N, L, and D, separated by spaces.
Print the earliest time when Kangto can hear the ringtone.
There is no additional hint.