#^. XHXMMMlOP0xMWg#,,^?
XHXMMMlOP0xMWg#,,^?
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
Statement
You are given two integers and .
In one operation, you can subtract any power of from . Formally, in one operation, you can replace by for any non-negative integer .
Find the minimum number of operations required to make equal to .
Format
Input
Each test contains multiple test cases. The first line contains the number of test cases ( ). The description of the test cases follows.
The only line of each test case contains two integers and ( ).
Output
For each test case, output the minimum number of operations on a new line.
Sample
6
5 2
3 5
16 4
100 3
6492 10
10 1
2
3
1
4
21
10
ShanghaiTech ACM 炸鱼杯
- 状态
- 已结束
- 规则
- OI
- 题目
- 46
- 开始于
- 2024-12-10 23:00
- 结束于
- 2024-12-15 13:00
- 持续时间
- 110 小时
- 主持人
- 参赛人数
- 112