-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution1.java
More file actions
25 lines (23 loc) · 778 Bytes
/
Solution1.java
File metadata and controls
25 lines (23 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import java.io.*;
import java.util.*;
public class Solution1 {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
ArrayList<String> names = new ArrayList<String>();
for (int i = 0; i < t; i++) {
int N = sc.nextInt();
int K = sc.nextInt();
int max = 0;
int current = 0;
for (int a = 1; a <= N; a++) {
current = (a & a-1);
if (current > max && current < K) {
max = current;
}
}
System.out.println(max);
}
}
}