Leaks in the Jutge (1) P21277


Statement
 

pdf   zip

thehtml

(This story is more or less based upon real facts.)

Some absent-minded professors inadvertently make the statement of a problem available to everyone the day before an exam. One student notices this fact, and in solidarity he warns k other students. Each one of them warns k other students (all different and who did not know yet), and so on. Knowing the total number of students n and the constant k, when will all students be aware?

Input

Input consists of several cases, each with two natural numbers n and k. Assume 1 ≤ n ≤ 106 and 1 ≤ k ≤ 1000.

Output

For every case, print the moment when all students will be aware. Suppose that the first student is aware at the moment 1, ant that transmitting the information requires one unit of time.

Public test cases
  • Input

    1 3
    2 3
    4 3
    5 3
    13 3
    14 3
    524287 2
    524288 2
    

    Output

    1
    2
    2
    3
    3
    4
    19
    20
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++