Problem Author: | AlKaosar Hussain |
Prepared by: | AlKaosar Hussain |
Edited by: | Hasan Saleh (MathModel) |
Solution
The function starts with ans = a_1
Every next step does
Bitwise AND can only remove bits, never add.
Therefore, the final value can never exceed .
So if we want f(p) = k then the simplest and safest choice is: a_1 = k
Once becomes , we just need to avoid removing its bits.
For remaining positions, choose any distinct integers that are \le 10^{18} because we are doing OR of a_1
with all number and finally ANDing them so when we OR we get those bits which we have in and as a_1=k so
ANDing them we left with so the answer is any sequence starts with and have distinct values.
Complexity .
for _ in range(int(input())):
n,k=map(int,input().split())
ans=[k]
cur=1
while(len(ans)<n):
if(cur!=k):
ans.append(cur)
cur+=1
print(*ans)