题号:NC14371
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 64 M,其他语言128 M
64bit IO Format: %lld
题目描述
DreamGrid has a nonnegative integer n, He would like to divide n into m nonnegative integers a1,a2,...am and minimizes their bitwise or (i.e:n = a1 + a2 + ... + am and a1 OR a2 OR ... OR am should be as small as possible).
输入描述:
There are multiple test cases. The first line of input contains an integer T, indicating the number of test cases. For each test case:
The first line contains two integers n and m (0 ≤ n < 101000,1 ≤ m < 10100)
It is guaranteed that the sum of n the length of does not exceed 20000.
输出描述:
For each test case, output an integer denoting the minimum value of their bitwise or.
示例1
输入
复制
5
3 1
3 2
3 3
10000 5
1244 10