• + 0 comments

    include

    include

    include

    include

    //Complete the following function.

    void calculate_the_maximum(int n, int k) { int temp = 0; int maxAND =0; int maxOR =0; int maxEXOR =0;

    for(int i = 1; i < n; i++) { for(int j = (i +1); j <= n; j++) {

          temp = i & j;
          maxAND =  ((temp > maxAND) && (temp < k)) ? temp : maxAND;
    
          temp = i | j;
          maxOR =  ((temp > maxOR) && (temp < k)) ? temp : maxOR;
    
          temp = i ^ j;
          maxEXOR =  ((temp > maxEXOR) && (temp < k)) ? temp : maxEXOR;
      }
    

    } printf("%d\n", maxAND); printf("%d\n", maxOR); printf("%d\n", maxEXOR); }

    int main() { int n, k;

    scanf("%d %d", &n, &k);
    calculate_the_maximum(n, k);
    
    return 0;
    

    }