You are viewing a single comment's thread. Return to all comments →
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> void calculate_the_maximum(int n, int k); int mand=0,mor=0,mxor=0; int main() { int n, k; scanf("%d %d", &n, &k); calculate_the_maximum(n, k); printf("%d\n%d\n%d",mand,mor,mxor); return 0; } void calculate_the_maximum(int n, int k) { for (int i=1;i<=n;i++) { for (int j=i+1;j<=n;j++) { if((i&j)<k && (i&j)>=mand) { mand=i&j; } if((i|j)<k && (i|j)>=mor) { mor=i|j; } if((i^j)<k && (i^j)>=mxor) { mxor=i^j; } } } }
Seems like cookies are disabled on this browser, please enable them to open this website
Bitwise Operators
You are viewing a single comment's thread. Return to all comments →