A XOR challenge
Practice
3.8 (29 votes)
Bitmask
Basic programming
Bit manipulation
Basics of bit manipulation
Greedy algorithms
Bit manipulation
Problem
93% Success 6454 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given an integer \(C\) such that the XOR of two integers \((A, B)\) is \(C\). In short \(A ⊕ B = C\) (⊕ denotes the bitwise the XOR operation).

Out of all possible pairs of \(A\) and \(B\), you must find two integers such that their product is maximum. 

Let us define \(L(A)\) as the length of \(A\) in its binary representation. Then, \(L(A) \le L(C)\) and \(L(B) \le L(C)\).

Input format 

A single integer representing \(C\) (\(0⩽C⩽10^5\))

Output format 

Print the maximum product you can achieve under the given conditions.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:50
2 votes
Tags:
MathematicsHardOpenApproved
Points:20
131 votes
Tags:
Bit manipulationEasyOpenSorting
Points:20
26 votes
Tags:
Basic ProgrammingBit ManipulationBit manipulationEasy