Last active
August 9, 2020 18:14
-
-
Save musou1500/f15609fb33599fcd7d6593aab872b168 to your computer and use it in GitHub Desktop.
三分探索
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
double l = 0, r = 1000; | |
for (int i = 0; i < 80; ++i) { | |
double c1, c2; | |
c1 = (l * 2 + r) / 3; | |
c2 = (l + r * 2) / 3; | |
if (f(c1) > f(c2)) { | |
l = c1; | |
} else { | |
r = c2; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment