Split-N Solutions Codechef

 

// Split N Solutions


Join My Whatsapp Group


 #include <iostream>

using namespace std;


int main() {

    int na ;

    cin>>na;

    while(na--){

        

        int sp;

        cin>>sp;

        int lk=0;

        while(sp!=0){

            int AB = 1;

            while(AB<=sp){

                AB=AB*2;

            }

            AB=AB/2;

            sp=sp-AB;

            lk++;

            

        }

        cout<<lk-1<<endl;

        

    }

  return 0;

}







Comments