Maximum AND
Practice
4.3 (56 votes)
Approved
Basic programming
Bit manipulation
Easy
Open
Problem
68% Success 17902 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code
Given two numbers A and B. Find the value of pair (P,Q) such that A <= P < Q <= B value of P AND Q is maximum where AND is a binary operator. Refer to this link for more information about AND operator : http://en.wikipedia.org/wiki/Bitwise_operation#AND
Input:
First line of input contains number of test cases T. Each test case contains two numbers A and B.
Output: For each test case print the value of maximum AND.
*Constraints: *
1<=T<=1000
1<= A < B <=1018
Sample Input
2 2 3 4 8
Sample Output
2 6
Code Editor
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
Submissions
Please login to view your submissions
Similar Problems
Points:20
11 votes
Tags:
BitmaskBasics of Bit ManipulationBasic ProgrammingBit ManipulationBit manipulationBasics of bit manipulation
Points:20
15 votes
Tags:
SortingBasic ProgrammingBit ManipulationMerge SortBasics of Bit ManipulationAlgorithmsBit manipulationBitmask
Points:20
602 votes
Tags:
Easy
Editorial
Login to unlock the editorial
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