Loading Now

snail_trip

Find the number of days it takes a snail to reach the top.

A snail is climbing a post of height H. Every day it climbs dmeters up. Then at night it sleeps, slowly slipping n meters down.

Your task is to calculate the number of days snail needs to climb onto the post.

Example:

  • For H = 30, d = 20, n = 10 the output should be Snail_trip(h,d,n)=2.
  • For H = 10, d = 12, n = 5 the output should be Snail_trip(h,d,n)=1.
  • For H = 0, d = 2, n = 1 the output should be Snail_trip(h,d,n)=0.

Input/Output:

  • [execution time limit] 0.5 seconds 

  • [input] integer H

    Post height 0 ≤ H ≤ 1000

  • [input] integer d

    The distance travelled up during the day  1 ≤ d ≤ 100.

  • [input] integer n

    The distance slipped down during the night 0 ≤ n < d.

  • [output] integer

    The answer to the task.

Post Comment

Contact