Problem Author: | Khoi Le |
Prepared by: | Khoi Le |
Edited by: | Hasan Saleh (MathModel) |
Observation : It's optimal to pick the integers with highest bits on
Notice for k \ge 2 we can pick two integers such that
We shall prove by construction :
Let x=2^{\lfloor \log_2(n) \rfloor}=10000...0 and y=x-1 i.e. then
If k=1 then the answer is .
def solve():
n,k=map(int,input().split())
if(k==1):
print(n)
else:
print((1 << n.bit_length())-1)
for _ in range(int(input())):
solve()