-
-
Notifications
You must be signed in to change notification settings - Fork 109
Expand file tree
/
Copy pathDay29:BitwiseAND.java
More file actions
28 lines (26 loc) · 700 Bytes
/
Day29:BitwiseAND.java
File metadata and controls
28 lines (26 loc) · 700 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
26
27
28
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
for(int a0 = 0; a0 < t; a0++){
int n = in.nextInt();
int k = in.nextInt();
int and=0;
int temp;
for(int i=1;i<n;i++){
for(int j=i+1;j<=n;j++){
temp=i&j;
if(temp<k)
if(temp>and)
and=temp;
}
}
System.out.println(and);
}
}
}