Input queries
Practice
1.6 (9 votes)
Bit manipulation
Basic programming
Basics of bit manipulation
Greedy algorithm
Problem
61% Success 1865 Attempts 50 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given $$Q$$ queries. Each input query contains three integers $$l$$, $$r$$, and $$k$$. Print the maximum bitwise AND value of a subset of size $$k$$ in the segment $$[l, r]$$.

Input format

  • The first line contains an integer $$Q$$ denoting the number of queries.
  • The first line of each query contains three space-separated integers $$l$$, $$r$$, and $$k$$.

Output format

Print the maximum bitwise AND value for each query in a new line.

Constraints

\(1 \le Q \le 2e5\\ 1 \le l \le r \le 1e18\\ 1 \le k \le r-l+1\)

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
23 votes
Tags:
Bit ManipulationBasic ProgrammingBasics of Bit ManipulationAlgorithms
Points:50
7 votes
Tags:
Basic ProgrammingBit Manipulation