随手用java写了下,点个赞吧 public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int all = sc.nextInt();//苹果总数 int[] arr = new int[all]; int i=0; for (int j = 0; j <all; j++) { arr[i++]=sc.nextInt(); } int temp = arr[0]; for (int j = 1; j < arr.length; j++) { temp=temp^arr[j]; } Arrays.sort(arr); int res = arr[0]; String s = Integer.toBinaryString(res); if (temp!=0){ System.out.println("-1"); }else { System.out.println(s); } } }

相关推荐

牛客网
牛客网在线编程
牛客网题解
牛客企业服务