• + 1 comment
    #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 maxAND = 0, maxOR = 0, maxXOR = 0;
      for (int a = 1; a < n; a++) {
        for (int b = 2; b < n + 1; b++) {
            if (b != a) {
                maxAND = (maxAND < (a&b) && (a&b) < k ) ? (a&b) : maxAND;
                maxOR = (maxOR < (a|b) && (a|b) < k ) ? (a|b) : maxOR;
                maxXOR = (maxXOR < (a^b) && (a^b) < k ) ? (a^b) : maxXOR; 
            }
        }
      }
      printf("%d\n%d\n%d\n", maxAND, maxOR, maxXOR);
    }
    
    int main() {
        int n, k;
      
        scanf("%d %d", &n, &k);
        calculate_the_maximum(n, k);
     
        return 0;
    }