Update

One new tab added. Open in browser view if it is not visible. (25/08/2022 08:48)

Make A and B equal

Language : C
(NOTE : Try a few times yourself before moving to the solution)


#include <stdio.h>
#include <math.h>
#include <stdbool.h>
 
bool isPowerOfTwo(int n)
{
    return (ceil(log2(n)) == floor(log2(n)));
}
 
int main(void) {
	int t;
	scanf("%d\n",&t);
	while(t--)
	{
	    int a, b;
	    
	    scanf("%d %d\n",&a,&b);
	    
	    if(a>b)
	    {
	        if(a%b==0 && isPowerOfTwo(a/b))
	            printf("YES\n");
	        else
	            printf("NO\n");
	    }
	    else
	    {
	        if(b%a==0 && isPowerOfTwo(b/a))
	            printf("YES\n");
	        else
	            printf("NO\n");
	    }
	}
	return 0;
}



No comments: