All submissions for this problem are available.
Given an integer, N. Convert this integer to binary and then if the Kth bit is not set then set the Kth bit otherwise leave it as it is. Then convert this binary to decimal M.
- The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
- The first and only line of each test case contains two space seperated integer N and K
- For each test case, output a single line containing the new number M
- 1 ≤ T ≤ 105
- 0 ≤ N ≤ 105
- 0 ≤ K ≤ 31
- All values are unsigned integer type
Input: 2 2 0 5 0 Output: 3 5
Example case 1.N = 2 which can be represented by 10 in binary, now if we set 0th bit then it becomes 11 which is equal to 3 in decimal
|Tags||bits, bitwise-operatn, easy, ince2019, prajapat786, prajapat786|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions