Skip to content

Instantly share code, notes, and snippets.

@musou1500
Last active August 9, 2020 18:14
Show Gist options
  • Save musou1500/f15609fb33599fcd7d6593aab872b168 to your computer and use it in GitHub Desktop.
Save musou1500/f15609fb33599fcd7d6593aab872b168 to your computer and use it in GitHub Desktop.
三分探索
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