[英]how to find the minimum value of z in the range l to r such that (x & z).(y & z) is maximum
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例如:- 如果 x=11,y=21,l=16 且 r=21,则在 l 到 r 范围内满足问题条件的 z 的最小值是 19 即 (11 & 19).(21 & 19 ) 是最大值
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.