Chef is given a contract to build towers in Chefland which are made by stacking blocks one above the other. Initially, there is only block in the inventory and no tower has been built. Chef follows the following steps in each operation:
- Either build a new tower or update an existing tower that has been built in previous operations using any number of blocks currently present in the inventory. After this step, the size of the inventory reduces by the number of blocks used.
- Suppose the tower Chef updated or built has blocks after the step, Chef gets to add new blocks to the inventory as a reward.
Find the maximum number of towers of height that Chef can build in operations.
Note: Tower of height means that the tower consists of blocks placed one above the other.
Input Format
- First line will contain , number of test cases. Then the test cases follow.
- Each test case contains a single line of input, two space separated integers .
Output Format
For each test case, output a single integer, the maximum number of towers that Chef can build.
Constraints
Sample Input 1
4
2 1
2 2
2 3
53 7
Sample Output 1
0
1
2
1
Solution:
click here for solution
No comments:
Post a Comment