You are given a sequence of 16N positive integers a1, a2, . . . , a 16N - You may shuffle this sequence in any way you choose, i.e. change it to any one of its permutations. Then, let (a1 Ð a2) ® (az Ð a4) ® ..® (a8N–1 O asn), y = (asN+1 Ð asN+2) ® (asN+3 Ð a8N+4) ® ...® (@16N–1 0 ¤16N), where O and O denote bitwise AND and XOR respectively. Find the maximum possible value of x – y.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 7PE
icon
Related questions
icon
Concept explainers
Question

Using C++ only

Example Input
1
1 1 1 2 1 1 1 2 1 1 1 2 1 1 1 2

Example Output
3

You are given a sequence of 16N positive integers a1, a2, . . ., a16N · You may
shuffle this sequence in any way you choose, i.e. change it to any one of its
permutations. Then, let
x = (a1 Ð a2) & (az O a4) ® . ..® (a8N-1 O asN),
y = (a8N+1 Ð a8N+2) ® (a8N+3 O a8N+4) ® ...® (@16N–1 O a16N),
where ® and O denote bitwise AND and XOR respectively.
Find the maximum possible value of x – y.
Transcribed Image Text:You are given a sequence of 16N positive integers a1, a2, . . ., a16N · You may shuffle this sequence in any way you choose, i.e. change it to any one of its permutations. Then, let x = (a1 Ð a2) & (az O a4) ® . ..® (a8N-1 O asN), y = (a8N+1 Ð a8N+2) ® (a8N+3 O a8N+4) ® ...® (@16N–1 O a16N), where ® and O denote bitwise AND and XOR respectively. Find the maximum possible value of x – y.
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Operators
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning