Under construction

Still being built. Things may change

Climbing Stairs

Interview

Time limit1sMemory limit512 MB

Summary
Given the required walk length n, the desk height r, and the office height k, find the minimum total steps walked in a day while starting and ending on the ground floor.
Level

Easy3 of 10

Topics
Math, Implementation, Greedy
Solved
No attempts yet

Problem

Your workplace recently announced a staircase cup with some fabulous prizes to win. The rules of participation are simple: Each day, it is possible to gain one point, and at the end of the month, whoever has the most points wins. In order to get a point for a specific day, you need to first walk n steps (either upwards or downwards) in the staircase, and thereafter you must register your achievement in the registration book at the registration desk.

While you would like to participate in the cup (the prizes are quite nice) you also do not like walking on stairs that much, and would like to know the minimal number of steps you need to walk each day in order to get a point. You also plan to spend most of your day in your office, and you will enter and leave the building through the only entrance on the ground floor. There are no elevators and no underground floors in the building.

Input

One line with three numbers n (1 ≤ n ≤ 1 000), r (0 ≤ r ≤ 1 000) and k (0 ≤ k ≤ 1 000), respectively indicating the number of steps required before you can register, the number of steps from the ground floor to the registration desk, and the number of steps from the ground floor to the floor of your office.

Output

The minimal number of staircase steps needed to participate in the staircase cup each day.

Examples1

  1. Example 1

    Input
    20 10 5
    
    Expected output
    30