IIITA1 - Playing With Bits

Maaz and Aradhya are quite brilliant students of Mathematics and Programming respectively. One day, their Mathematics Professor Mr. K.P. Singh asked them to solve a Mathematics problem.

Given two number A and B, find the minimum number of bits required to convert binary representation of A into binary representation of B.

Maaz promised Mr. K.P. Singh that he will be the first one to solve the problem but Aradhya decided to do it before him. He turns to you for help. Will you be able to help him?

Input

Input consists of t (number of test cases), then t lines follows, each containing two integers A and B (1 <= A, B <= 2^31)

Output

A single line containing the minimum number of bits required to convert binary representation of  A into binary representation of B.

Example

Input:
2
14 31
56 68
Output:
2
5

Time Limit is kept very strict. Any naive algorithm will never be accepted. 


Added by:Better late than never !!!
Date:2012-08-25
Time limit:0.100s
Source limit:500B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All
Resource:Navneet Sir

hide comments
2013-05-15 07:56:15 victor gomez
can some one doa tutorial, i need to solve this problem for a final exam; //plis should be in C++

Last edit: 2013-05-15 07:57:11
2012-08-26 21:15:52 :D
Please don't set up such ridiculous times in the main problem set.

Also what do you mean by brute force? I think iterative approach with fast reading/writing will pass either way (I'll maybe check that tomorrow). The time here should simply be the IO time. Finally it's really basic so it lands in tutorial.

Last edit: 2012-08-27 05:51:46
2012-08-26 16:31:09 StupidGuy
So, finally tutorial it is...
2012-08-26 16:31:09 Shubham
@better late than never,problemID 7534417 and 7534410 are exactly the same but one got accepted and other one showed TLE. And by exact I mean exact.look into this please.

RE -> This is all due to SPOJ machine. If their is load on spoj machine execution time of the solution increases. And since time limit is kept strict, that might lead to TLE.

Last edit: 2012-08-26 20:13:49
2012-08-26 16:31:09 mehmetin
As pointed out by S#!THAPPEN$, the judge can give TLE for no reason. It happens with other problems too. It must have something to do with the system.
2012-08-26 16:31:09 Francky
Solution had been rejudged and I loose my 0.07s :-(
Why rejudge ? For the new strict time limit ? What a joke.
Move it to tutorial or challenge as many people ask to, please.
2012-08-26 16:31:09 Secret
it should be moved to tutorial .
2012-08-26 16:31:09 Alex Anderson
This should be tutorial or challenge.
2012-08-26 16:31:09 Aradhya
:D check my submissions in id's 7532238 and 7532240.. not even a single character change :D one AC and one TLE.. lol on spoj machines
2012-08-26 16:31:09 Aradhya
my c++ code which took 0.09 sec ,, got TLE in PYTH o.O.. reset the time limit snehasish
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.