Leaks in the Jutge (1) P21277


Statement
 

pdf   zip

(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 kk other students. Each one of them warns kk other students (all different and who did not know yet), and so on. Knowing the total number of students nn and the constant kk, when will all students be aware?

Input

Input consists of several cases, each with two natural numbers nn and kk. Assume 1n1061 \le n \le 10^6 and 1k10001 \le k \le 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++