Lucky and Arrays
All submissions for this problem are available.
Lucky has an array of N elements [a1, a2, a3, ....,an]. Bunny decided to play a game with the array. So he gave another array which have N elements [b1, b2, b3, ...., bn] and ask her to find the minimum number of bits required to change ai to bi. Let's consider ai = 4 and bi = 3 binary values of 4 and 3 are 100 and 011, we need 3 bits to change 4 to 3.
She needs your help to solve this problem.
- The first line of the input contains an integer N denotes number of elements in the arrays.
- For next N lines, each line contains two integers(ai and bi) separated by space
- Output N lines, each line contains minimum number of bits require to change ai to bi.
- 1 ≤ N ≤ 105
- 1 ≤ ai, bi ≤ 109
Input: 2 1 3 4 3 Output: 1 3
For 1 and 3 binary values are 01 and 11, so we need to change 1 bit for get 3 from 1
|Time Limit:||0.5 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, 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, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions