10019 - Funny Encryption Method

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n;
    for(int t=1;t<=n;t++)
    {
        int bc=0,hc=0,h=0;
        cin>>m;
        int b=m;
        while(m!=0)
        {
            if((m&1)==1)
                bc++;
            m>>=1;
            //cout<<(m&1)<<endl;
        }

        h+=(b/10000)*pow(16,4);
        b%=10000;
        //cout<<h<<endl;

        h+=(b/1000)*pow(16,3);
        b%=1000;
        //cout<<h<<endl;

        h+=(b/100)*pow(16,2);
        b%=100;

       // cout<<h<<endl;
        h+=(b/10)*pow(16,1);
        b%=10;
        //cout<<h<<endl;
        h+=b;
        //cout<<h<<endl;

         while(h!=0)
         {
            if((h&1)==1)
                hc++;
            h>>=1;
            //cout<<(m&1)<<endl;
         }
        cout<<bc<<" "<<hc<<endl;
    }
    return 0;
}

SHARE

Amit Ghosh

    Blogger Comment
    Facebook Comment

0 comments :

Post a Comment