#BS0000247. Lập trình xuyên đêm (Burning Midnight Oil)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Lập trình xuyên đêm (Burning Midnight Oil)
Burning Midnight Oil
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Vasya must write at least lines of code overnight. He writes lines in the first session, takes a tea break, and writes lines in the next session. Session produces lines for . He falls asleep when a session would produce zero lines and writes no more. Find the smallest positive integer that allows him to finish at least lines.
Input
The only line contains integers : the required number of lines and the productivity reduction factor.
Output
Print the smallest positive integer meeting the requirement.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
7 2
Output
4
Explanation
For , the sessions produce 4, 2, and 1 lines, totaling 7. For , the total is only . Since increasing never decreases the total, the answer is 4.
Input
59 9
Output
54
Explanation
With , the total is . With , it is only . Thus the minimum is 54.