Help me in solving COOKMACH problem

My issue

TLE error!
Is my approach correct?

My code

#include <stdio.h>
#include <math.h>
int main(void) {
	// your code goes here
	int T;
	scanf("%d\n", &T);
	for(int i=0; i<T; i++){
	    long int A, B;
	    int count=0;
	    scanf("%ld %ld", &A, &B);
	    while(A){
	        if(A==B){
	            A=0;
	        }
	        else if(A>B){
	            if(A%2==0){
	                count++;
	                A/=2;
	            }
	            else{
	                count++;
	                A=(A-1)/2;
	            }
	        }
	        else{
	            if(A%2==0||A==1){
	                count++;
	                A*=2;
	            }
	            else{
	                count++;
	                A=(A-1)/2;
	            }
	        }
	    }
	    printf("%d\n", count);
	}
	return 0;
}


Problem Link: COOKMACH Problem - CodeChef

@gnaneswar14
your approach is not right u have to think of it greedily like make A power of 2 first then make A to B if A is not power of 2 there is no point of making A to B to make A power of two just divide it by two and check at every division that whether it becomes power of 2 or not