-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay29.java
More file actions
24 lines (22 loc) · 719 Bytes
/
Copy pathDay29.java
File metadata and controls
24 lines (22 loc) · 719 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
import java.io.*;
import java.util.*;
public class Solution {
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 n = sc.nextInt();
for(int i=0;i<n;i++){
int max = 0;
int number = sc.nextInt();
int k = sc.nextInt();
for(int j=1; j< number; j++){
for(int m=j+1; m<=number; m++){
if((j&m) < k)
if((j&m)>max)
max = j&m;
}
}
System.out.println(max);
}
}
}