RPOWER from Ramayan

How to solve RPOWER ?

We have to find the minimum c to get maximum value for strength=( ( ( ( a ^ b ) | c ) ^ d ) | e ) where a,b,d,e are given and c < 2 power 60. (^ - binary XOR operator , | binary or operator )
firstly, a^b is a new constant say f.
we wish that the strength has every bit set (it may or may not be possible).
since the last operation is an or, if any bit is set in e we don’t need to think about bit in c . to minimise c we can make it zero simply.
let’s consider a few cases when bit in e is 0.:thinking:

  1. if the same bit in d and f is also zero then it must be set in c .

  2. if that bit is set in d then we wish to not set it in f|c so we should make it 0 in c but we can do
    nothing about it in f as it’s given.
    so finally whenever a certain bit is not set in all three e,f,and d , set it in c

#include <stdio.h>
typedef long long int ll;
int main(void) {
ll a,b,c,d,e,t,T;
ll ans=0,ch;
for(int i=0;i<60;i++){
return 0;

link to solution. https://www.codechef.com/viewsolution/33165208

Thanks :slight_smile: