l = 0, h = n-1;
while (h - l > 1) // a.k.a. (h - l) >=2 --> l < (l+h)/2 < h
{
mid = (l+h)/2;
if P(mid) l = mid;
else h = mid;
}
for (i = h; i>=l; i--)
{
if P(i) return i;
}
assert(false);
bCA9IDAsIGggPSBuLTE7CndoaWxlIChoIC0gbCA+IDEpIC8vIGEuay5hLiAoaCAtIGwpID49MiAtLT4gbCA8IChsK2gpLzIgPCBoCnsKCW1pZCA9IChsK2gpLzI7CiAgIAlpZiBQKG1pZCkgbCA9IG1pZDsKICAgCWVsc2UgaCA9IG1pZDsKfQpmb3IgKGkgPSBoOyBpPj1sOyBpLS0pCnsKCWlmIFAoaSkgcmV0dXJuIGk7Cn0KYXNzZXJ0KGZhbHNlKTs=
Main.java:1: error: class, interface, or enum expected
l = 0, h = n-1;
^
Main.java:2: error: class, interface, or enum expected
while (h - l > 1) // a.k.a. (h - l) >=2 --> l < (l+h)/2 < h
^
Main.java:5: error: class, interface, or enum expected
if P(mid) l = mid;
^
Main.java:6: error: class, interface, or enum expected
else h = mid;
^
Main.java:7: error: class, interface, or enum expected
}
^
Main.java:8: error: class, interface, or enum expected
for (i = h; i>=l; i--)
^
Main.java:8: error: class, interface, or enum expected
for (i = h; i>=l; i--)
^
Main.java:11: error: class, interface, or enum expected
}
^
8 errors