File size: 742 Bytes
c4b0eef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <cstdio>
#include <iostream>

using namespace std;

int dec_bin(int a)
{
    int temp, one = 0;
    while( a!=0 )
    {
        temp = a%2;
        a /= 2;

        if( temp==1 ) ++one;
    }
    return one;
}

int hex_bin(int a)
{
    int temp, one = 0;
    while( a!=0 )
    {
        temp = a%10;
        a /= 10;

        if( temp==1 || temp==2 || temp==4 || temp==8 ) ++one;
        else if( temp==3 || temp==5 || temp==6 || temp==9 ) one += 2;
        else if( temp==7 ) one += 3;
    }
    return one;
}

int main()
{
    int tc;

    cin >> tc;
    while( tc-- )
    {
        int M;
        cin >> M;

        int b1 = dec_bin(M);
        int b2 = hex_bin(M);

        cout << b1 << " " << b2 << endl;
    }
    return 0;
}