File size: 596 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 |
#include <cstdio>
using namespace std;
int bits(int hexDigit) {
switch(hexDigit) {
case 0: return 0;
case 1: return 1;
case 2: return 1;
case 3: return 2;
case 4: return 1;
case 5: return 2;
case 6: return 2;
case 7: return 3;
case 8: return 1;
case 9: return 2;
}
return 0;
}
int main() {
int N;
scanf("%d", &N);
for (int i = 0; i < N; i++) {
int M1, M2, b1 = 0, b2 = 0;
scanf("%d", &M1);
M2 = M1;
while (M1 != 0) {
b1 += M1 % 2;
M1 = M1 >> 1;
}
while (M2 != 0) {
b2 += bits(M2 % 10);
M2 /= 10;
}
printf("%d %d\n", b1, b2);
}
return 0;
} |