BBALLS - Bouncing Balls

Problem link : CodeChef: Practical coding for everyone

Binary form of total distance will show how many minimum powers of 2 total distance can be divided into which is the required answer.

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007


int main(){
    ll test;
    cin >> test;
    while(test--){
        ll num;
        ll one  = 1;
        cin >> num;
        int count = 0;
        for(int i = 0; i < 63; i++){
            if(((num>>i)&one)){
                count++;
            }
        }      
        cout << count - 1<< endl;

    }
    return 0;
}