Don't Think Any Approach will you suggest me

How to approach any hint or explanation

hi @mohit26900
This is a quite simple problem to tackle. Just loop through all the numbers between a and b and calculate the no of set bits (set bits means 1’s in binary representation of a number)

refer this code -->

#include<iostream>
using namespace std;
int main(){
	
	int t;
	cin>>t;
	
	for(int i=0;i<t;i++){
        int a,b;
        cin>>a>>b;
        
        int count = 0;
        for(int j=a;j<=b;j++){
            int num = j;   
            while(num>0){
                int rem = num%2;
                if(rem == 1){
                    count++;
                }
                num=num/2;
            }
        }
        cout<<count<<endl;
	}
}

My code is this but it showing TLE

hi @mohit26900
Is it resolved now as I can see u have successfully submitted the code and gained full points

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.