Input queries

1.6

9 votes
Bit Manipulation, Basic Programming, Basics of Bit Manipulation, Greedy algorithm
Problem

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

1Q2e51lr1e181krl+1

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

For the first query, there is only 1 possible subset {8}.

For the third query, the maximum possible AND value is only possible for subset {4,5,6}.

Editor Image

?