We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#include<stdio.h>#include<string.h>#include<math.h>#include<stdlib.h>//Complete the following function.voidcalculate_the_maximum(intn,intk){//Write your code here.intsumor=0,sumand=0,sumxor=0;for(inti=1;i<n;i++){for(intj=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);}intmain(){intn,k;scanf("%d %d",&n,&k);calculate_the_maximum(n,k);return0;}
Cookie support is required to access HackerRank
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 →