Let [Math Processing Error]
denote the number of set bits in [Math Processing Error].
Given integers [Math Processing Error] and [Math Processing Error], construct an array [Math Processing Error] of length [Math Processing Error] such that:
- [Math Processing Error] for all [Math Processing Error];
- [Math Processing Error]
Over all such possible arrays, find the maximum value of [Math Processing Error].
Input Format
- The first line of input contains a single integer [Math Processing Error] - the number of test cases. The description of [Math Processing Error] test cases follow.
- The only line of each test case contains integers [Math Processing Error] and [Math Processing Error]- the length of the array and sum of elements respectively.
Output Format
For each test case, output the maximum value of [Math Processing Error].
Constraints
- [Math Processing Error]
- [Math Processing Error]
- [Math Processing Error]
Sample Input 1
2
1 7
3 6
Sample Output 1
3
4
Explanation
Test case [Math Processing Error]: Only one array is possible that is [Math Processing Error]. As [Math Processing Error], the number of set bits in [Math Processing Error] is [Math Processing Error]. Thus, [Math Processing Error].
Test case [Math Processing Error]: A possible array satisfying all the conditions is [Math Processing Error]. As [Math Processing Error], the number of set bits in [Math Processing Error] is [Math Processing Error]. Similarly, the number of set bits in [Math Processing Error] is [Math Processing Error]. Thus, [Math Processing Error]. It can be proven that answer never exceeds [Math Processing Error].
No comments:
Post a Comment