Roy and Maximum XOR
Practice
3 (2 votes)
Ad Hoc
Mathematics
Open
Approved
Easy
Problem
61% Success 7264 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Roy has a matrix of size NxN. Rows and Columns are numbered from 0 to N-1.
jth column of ith row contains i xor j.

In other words, Matrix[i][j] = i ^ j where 0 ≤ i,j < N. ( ^ is a bitwise operation used in C/C++ for xor, please use appropriate symbol if you're using any other language)

Your task is to find the maximum value occurring in this matrix and the count of its occurrence.

Input:
First line contains T - number of test cases
Following T lines each contains an integer N - size of matrix

Output:
For each test case output the maximum value and its count separated by a space in a new line.

Constraints:
1 ≤ T ≤ 100000 (105 )
1 ≤ N ≤ 1000000000000000000 ( 1018 )

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:20
3 votes
Points:20
Tags:
Easy
Points:20
7 votes
Tags:
MathematicsOpenApprovedEasyMathamatics