There was an error while loading. Please reload this page.
1 parent d18e6e6 commit d05f11dCopy full SHA for d05f11d
Binary Search/BS on real values template
@@ -0,0 +1,20 @@
1
+double eps = 1e-6;
2
+int limit = 0;
3
+
4
+// good function checks whether the searching value is valid or not.
5
6
+bool good(double m) {
7
+ // implement the standard good func;
8
+ // m is the value you are searching for
9
+}
10
11
+double f() {
12
+ double l = 0, r = limit;
13
+ double ans = l;
14
+ for(int i=0;i<200 && l+eps <= r;i++) {
15
+ double mid = (l+r)/2;
16
+ if(good(mid)) ans = mid, // r = mid or l = mid;
17
+ else // l = mid or r = mid;
18
+ }
19
+ return ans;
20
0 commit comments