import Data.Word
main = do
let ls = [262734068,1284266430,850241238,1854436759,925227574,1072391605,
1593098480,753973039,1320460728,1653753372,1036510631,1372732547,
2027209822,1573664868]
searchX :: Word32 -> Word32
where
f l r
| r - l > 0 = f l' r'
where
(l', r') =
case aboutX x m of
0 -> (r , m)
1 -> (l , m)
-1 -> (m + 1, r)
m
= (+) =<< (`
div`
2) . (r
-) $ l
aboutX :: Word32 -> Word32 -> Word32
aboutX x a =
EQ -> 0
GT -> 1
LT -> -1
aW1wb3J0IERhdGEuV29yZAoKbWFpbiA6OiBJTyAoKQptYWluID0gZG8KICBsZXQgbHMgPSBbMjYyNzM0MDY4LDEyODQyNjY0MzAsODUwMjQxMjM4LDE4NTQ0MzY3NTksOTI1MjI3NTc0LDEwNzIzOTE2MDUsCiAgICAgICAgICAgIDE1OTMwOTg0ODAsNzUzOTczMDM5LDEzMjA0NjA3MjgsMTY1Mzc1MzM3MiwxMDM2NTEwNjMxLDEzNzI3MzI1NDcsCiAgICAgICAgICAgIDIwMjcyMDk4MjIsMTU3MzY2NDg2OF0KICBwcmludCAkIG1hcCBzZWFyY2hYIGxzCgpzZWFyY2hYIDo6IFdvcmQzMiAtPiBXb3JkMzIKc2VhcmNoWCB4ID0gZiAwIG1heEJvdW5kCiAgd2hlcmUKICAgIGYgbCByCiAgICAgIHwgciAtIGwgPiAwID0gZiBsJyByJwogICAgICB8IG90aGVyd2lzZSA9IHIKICAgICAgd2hlcmUKICAgICAgICAobCcsIHInKSA9CiAgICAgICAgICBjYXNlIGFib3V0WCB4IG0gb2YKICAgICAgICAgICAgMCAgLT4gKHIgICAgLCBtKQogICAgICAgICAgICAxICAtPiAobCAgICAsIG0pCiAgICAgICAgICAgIC0xIC0+IChtICsgMSwgcikKICAgICAgICBtID0gKCspID08PCAoYGRpdmAgMikgLiAociAtKSAkIGwKCmFib3V0WCA6OiBXb3JkMzIgLT4gV29yZDMyIC0+IFdvcmQzMgphYm91dFggeCBhID0KICBjYXNlIGNvbXBhcmUgYSB4IG9mCiAgICBFUSAtPiAwCiAgICBHVCAtPiAxCiAgICBMVCAtPiAtMQo=
[262734069,1284266431,850241239,1854436767,925227575,1072391607,1593098481,753973055,1320460729,1653753373,1036510639,1372732551,2027209823,1573664869]