• + 0 comments
    #include <stdio.h>
    #include <string.h>
    #include <math.h>
    #include <stdlib.h>
    //Complete the following function.
    
    
    void calculate_the_maximum(int n, int k) {
      int max_xor = 0, max_and = 0, max_or = 0, or = 0, xor = 0, and = 0;
    
      for(int i = 1; i <= n; i++)
      {
        for(int j = i+1; j <= n; j++)
        {
            or = i | j;
            and = i & j;
            xor = i ^ j;
    
            if(max_or < or && k > or) max_or = or;
            if(max_xor < xor && k > xor) max_xor = xor;
            if(max_and < and && k > and) max_and = and;
        }
      }
      printf("%d \n%d \n%d \n", max_and, max_or, max_xor);
    }
    
    int main() {
        int n, k;
      
        scanf("%d %d", &n, &k);
        calculate_the_maximum(n, k);
     
        return 0;
    }