Elevator
Time limit1sMemory limit1024 MB
Given the elevator's floor k, Misha's floor n, and the per-floor times a (stairs) and b (elevator), find the time to reach floor n by each method.
- Level
Easy1 of 10
- Topics
- Implementation, Math
- Solved
- No attempts yet
Problem
Misha lives on floor . When Misha enters the building, he checks which floor the elevator is on at that moment and decides whether to call the elevator or take the stairs.
Today the elevator is on floor . Misha enters the building on floor 1. Climbing one floor by the stairs takes seconds. The elevator moves one floor in seconds. Time spent entering or leaving the elevator, and time spent walking to the stairs or the elevator and back, can be ignored.
Help Misha decide by computing how long it takes him to reach his floor by elevator and by stairs.
Input
The input contains four integers , , , and .
, , .
Output
Print two integers. The first is the time it takes Misha to reach his floor by elevator, and the second is the time it takes him to climb to his floor by stairs.
Hint
In the example, the elevator needs seconds to come down from floor 8, and then seconds to go up to floor 15, where Misha lives. Misha needs seconds to climb to floor 15 by the stairs.