1 (Nanyang oj100) and 1 (Nanyang oj100)
1 Number of time limit: 3000 MS | memory limit: 65535 KB difficulty: 1
-
Description
-
Xiaonan has learned binary. He wants to know the number of 1 in the Binary Expression of a number. Can you help him write a program to complete this task?
-
Input
-
Enter an integer N in the first line, indicating the number of groups of test data (1 <N <1000)
Each group of test data has only one row, which is an integer M (0 = <M <= 10000)
-
Output
-
Each group of test outputs occupies one row, and the output M binary represents the number of 1
-
Sample Input
-
3467
-
Sample output
-
123
-
Source
-
[Zhang yuncong] original
-
Uploaded
Zhang yuncong
# Include <stdio. h> int main () {int test, n, ans; scanf ("% d", & test); while (test --) {scanf ("% d ", & n); ans = 0; while (n) {if (n % 2) ans ++; n/= 2;} printf ("% d \ n ", ans);} return 0 ;}