#P2405. non天平
non天平
Description
The weights each have masses that are powers of : , and so on. non wants to know the minimum number of weights needed to measure his weight . Note that weights can be placed on either the left or the right pan.
Input Format
The first line contains a non-negative integer , representing non's weight.
The second line contains a positive integer , representing the base of the powers for the weights.
Output Format
Output a single integer representing the minimum number of weights required.
99
10
2
Hint
Constraints
For of the testdata, .
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号