We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
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 finalResult = 0;
for(int i = 1; i < n ; i++){
for(int j = i+1; j <= n ; j++){
int amp = i&j;
if(amp < k && amp > finalResult)
finalResult = amp;
}
}
System.out.println(finalResult);
}
}
Day 29: Bitwise AND
You are viewing a single comment's thread. Return to all comments →
My Answer is :