Problem
Submission
What am I missing?
if(remaining_elements%2==0){
cout<<(x+remaining_elements)<<"\n";
}else{
if(on_bits<=1){
if(remaining_elements==1){
if(x==1){
cout<<(x+4)<<"\n";
}else{
cout<<(x+n)<<"\n";
}
}else{
cout<<( x+remaining_elements+3)<<"\n";
}
}else{
cout<<(x+remaining_elements+1)<<"\n";
}
}
}
cout<<(x+4)<<"\n" this is pretty much handles a case, if x==1 and there are only one remaining_element i.e n=2
cout<<(x+n)<<"\n", this is when $$$x=2^i$$$ where $$$i \gt 0$$$ and remaining_elements = 1 i.e when n=2
cout<<(x+remaining_elements+3)<<"\n", this handles when we have $$$x=2^i$$$ for $$$i \gt 0$$$ and remaining_elements = {3, 5, ...}
We can generalize this, since remaining_elements will be odd $$$ \gt =3$$$ we can set 0th bit on for all remaining_elements, upto
(remaining_elements-1) then we set 1st bit($$$2^1$$$) for last element and last second so in total : $$$x+(RemainingElements-1)+2+2$$$
so where does this fail?



