• + 0 comments

    void calculate_the_maximum(int n, int k) { int a, b; int AND, OR, XOR; int maxAND = 0; int maxOR = 0; int maxXOR = 0;

    for (int i = 1; i < n; i++){
        for (int j = i + 1; j <= n; j++){
            a = i;
            b = j;
            AND = a & b;
            OR = a | b;
            XOR = a ^ b;
    
            if (AND < k){
                if (maxAND < AND){maxAND = AND;}
            }
            if (OR < k){
                if (maxOR < OR){maxOR = OR;}
            }
            if (XOR < k){
                if (maxXOR < XOR){maxXOR = XOR;}
            }
            }   
        }
    printf("%d\n%d\n%d", maxAND, maxOR, maxXOR);
    

    }

    int main() { int n, k;

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

    }