For eg:- if x=11,y=21,l=16 and r=21,then the minimum value of z satisfying the question's condition in the range l to r is 19 ie (11 & 19).(21 & 19) is maximum
i can't figure out how to solve this question for large range
Pseudo-code:
pos = 0 //current position of largest (x&z)(y&z)
largest = -1
for z = 1 to r do
candidate = (x&z)(y&z)
if candidate > largest then
largest = candidate
pos = z
//result is pos here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.