摘要:
归并排序 1、确定分界点:mid = (l + r) / 2 2、递归排序left, right 3、归并 合二为一 模板 注意l 和 1 的区分 #include<bits/stdc++.h> //万能头文件 using namespace std; const int N = 1000010; 阅读全文
摘要:
浮点数二分 模板 假如求平方根 #include<bits/stdc++.h> //万能头文件 using namespace std; int main() { double x; cin>>x; double l = 0, r = max(1, x); while (r - l > 1e-8) 阅读全文
摘要:
整数二分 二分的本质并不是单调性,有单调性一定可以二分,无单调性也可能可以二分。 模板代码如下: #include<bits/stdc++.h> //万能头文件 using namespace std; int check(int mid) { } //区间[l, r]被划分成[l, mid]和[m 阅读全文