149 在其它数都出现k次的数组中找到只出现一次的数
Table of Contents

ac

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static Scanner sc = new Scanner(System.in);

    public static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

    public static long mod = (long)Math.pow(2,29);

    public static void main(String[] args) throws Exception {
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] arr = new int[n];
        for(int i=0;i<n;i++){
            int val = sc.nextInt();
            arr[i] = val;
        }
        int[] bitCnt = new int[32];
        for(int i=0;i<n;i++){
            for(int m=31;m>=0;m--){
                if(((arr[i] >> m) & 1) == 1){
                    bitCnt[m] ++;
                }
            }
        }
        int ans = 0;
        for(int i=0;i<32;i++){
           if(bitCnt[i] % k != 0){
               ans = ans + (1 << i);
           }
        }
        System.out.println(ans);

    }

}
/*
7 3
5 4 1 1 5 1 5

4
*/