• + 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) {
      //Write your code here.
      int sumor = 0, sumand = 0, sumxor = 0; 
      for(int i = 1; i < n; i++){
        for(int j = i+1; j <= n; j++){
           if(sumand < (i & j) && (i & j) < k)
             sumand = i & j;
           if(sumor < (i | j) && (i | j) < k)
             sumor = i | j;
           if(sumxor < (i ^ j) && (i ^ j) < k)
             sumxor = i ^ j;
        }  
      }
      printf("%d\n%d\n%d",sumand,sumor,sumxor);
    }
    
    int main() {
        int n, k;
      
        scanf("%d %d", &n, &k);
        calculate_the_maximum(n, k);
     
        return 0;
    }