题解 | #牛牛的10类人#
牛牛的10类人
http://www.nowcoder.com/practice/232b7fc32fac4636819e31a7d7c960a3
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner scanner = new Scanner(System.in); int count = scanner.nextInt(); int[] nums = new int[count]; int[][] checks = new int[count][2]; for(int index = 0; index < count; index++){ nums[index] = scanner.nextInt(); } for(int index = 0; index < count; index++){ int zeroCount = 0; int oneCount = 0; int number = nums[index]; while(number != 0){ int bit = number & 1; if(bit == 0){ zeroCount++; }else if(bit == 1){ oneCount++; } number >>>= 1; } checks[index][0] = zeroCount; checks[index][1] = oneCount; } for(int index = 0; index < count; index++){ if((checks[index][0] & 1) == 0 && (checks[index][1] & 1) == 0){ System.out.print("10 "); }else if((checks[index][0] & 1) == 0){ System.out.print("0 "); }else if((checks[index][1] & 1) == 0){ System.out.print("1 "); }else{ System.out.print("100 "); } } } }