Mr. Benzene wants permission to go on a bachelor trip, but his mathematician wife isn't convinced.
She says:
Solve this math problem first — or you're cleaning the room all week!"
Mr. Benzene must find the smallest non-negative integer $$$\mathbf{n}$$$ such that the number of ways to express $$$\mathbf{n}$$$ as the sum of exactly $$$\mathbf{k}$$$ non-negative integers is at least $$$\mathbf{m}$$$. If he fails, he faces a week of messy floors and dust bunnies.
The first line contains an integer $$$\textbf{T}$$$ $$$(1 \leq $$$T$$$ \leq 10^{5})$$$ the number of test cases.
Each of the next $$$T$$$ lines contains two integers $$$\textbf{k}$$$ and $$$\textbf{m}$$$ $$$(1 \leq $$$k$$$ ,\, $$$m$$$ \leq 10^{18})$$$.
For each test case, output Case $$$\mathbf{X: n}$$$, where $$$\mathbf{X}$$$ is the test case number (starting from 1) and $$$\mathbf{n}$$$ is the smallest integer that satisfies the condition, or $$$\mathbf{-1}$$$ if no such answer exists.
3 3 15 3 16 5 35
Case 1: 4 Case 2: 5 Case 3: 3
Consider the first test case: $$$\mathbf{k = 3}, \mathbf{m = 15}$$$. Iterative approach:
So, the answer is $$$\mathbf{4}$$$.