DWITE '12 R2 #1 - Sugar Rush

View as PDF

Submit solution

Points: 3
Time limit: 2.0s
Memory limit: 64M

Problem type
DWITE, November 2012, Problem 1

After collecting all the candy you could get at Halloween, you decided to eat all of that candy as fast as possible! However, after having eaten some of them you get a sugar rush, enabling you to eat the remaining pieces even faster! Before starting, you want to calculate how long it will take you to eat all of your candy. From previous Halloweens, you noticed that you start eating one piece of candy at a time (i.e. one piece per mouthful). However, after having eaten C pieces, the sugar rush kicks in and you can eat twice as many pieces of candy at a time. Then after having eaten another C pieces, the amount you can eat at a time is doubled yet again! This continues until you finish all of your candy!

Note: you can only get one sugar rush at a time, even if you eat 2C pieces of candy in one go.

The input will contain 5 test cases. Each test case is a line with two integers, 1 \le N, C \le 100, representing the number of pieces of candy you have and the count of pieces necessary for the sugar rush respectively.

The output will contain 5 lines of output. Each a single integer — the minimum number of mouthfuls necessary to eat all N pieces of candy, in each of the test cases.

Sample Input

10 1
10 5

Sample Output

4
8

Problem Resource: DWITE

Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported

Comments

There are no comments at the moment.