Skip to content

nureto21/Bitwise-XOR-Equalization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

You are given an array A consisting of N integers and an integer X. Your goal is to have as many equal integers as possible in the array. To achieve this goal, you can do the following operation: · Choose an index i(1≤i≤N) and set Ai​=Ai​⊕X, where ⊕ denotes the bitwise xor operation. Find the maximum number of equal integers you can have in the final array and the minimum number of operations to obtain these many equal integers. Input Format · The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows. · Each test case contains two lines of input. · The first line of each test case contains two space-separated integers N, X. · The second line of each test case contains N space-separated integers A1,A2,...,AN. Output Format For each test case, print a single line containing two space-separated integers - first, the maximum number of equal integers in the final array and second, the minimum number of operations to achieve these many equal integers.

Constraints · 1≤T≤10^4 · 1≤N≤10^5 · 0≤X≤10^9 · 0≤Ai≤10^9 · The sum of N over all test cases does not exceed 5⋅10^5.

About

Check README file for additional description of this JavaScript program.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published