摘要: 首先先讲位运算两个比较重要的知识点 求n的第K位数字:n>>k&1 返回n的最后一位1 :lowbit(n)=n&-n; #include<iostream> using namespace std; int n; const int N = 100010; int a[N]; int lowbit 阅读全文
posted @ 2020-02-23 01:39 想拿牌想考研的菜鸡 阅读(127) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> using namespace std; int n,res; const int N=100010; int a[N],s[N]; int main() { cin>>n; for(int i=0;i<n;i++)cin>>a[i]; for(int i=0, 阅读全文
posted @ 2020-02-23 01:32 想拿牌想考研的菜鸡 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 前缀和分一维前缀和和二维前缀和,前缀和可以帮我们快速统计一段范围内的合。 需要简单的理解 一维前缀和 —— 模板题 AcWing 795. 前缀和S[i] = a[1] + a[2] + ... a[i];a[l] + ... + a[r] = S[r] - S[l - 1]; 二维前缀和 —— 模 阅读全文
posted @ 2020-02-20 01:54 想拿牌想考研的菜鸡 阅读(255) 评论(0) 推荐(0) 编辑
摘要: 高精度乘法一般都是由一个大数乘以一个可以由int存放的整数类型。 #include <iostream> #include <vector> using namespace std; vector<int> mul(vector<int> &a,int b){ int t = 0; vector<i 阅读全文
posted @ 2020-02-20 01:38 想拿牌想考研的菜鸡 阅读(211) 评论(0) 推荐(0) 编辑
摘要: 首先讲一下大数相加其实代码模拟的过程就是模拟小学的加法法则。因为C语音的LL double等太少不能求位数过多的加减法。 下面让我们一起分析一下代码 1 #include<iostream> 2 #include<vector> 3 using namespace std; 4 5 vector<i 阅读全文
posted @ 2020-02-19 02:45 想拿牌想考研的菜鸡 阅读(382) 评论(0) 推荐(0) 编辑
摘要: 这里带来一手整数的二分模板。 bool check(int x) {/* ... */} // 检查x是否满足某种性质 // 区间[l, r]被划分成[l, mid]和[mid + 1, r]时使用: int bsearch_1(int l, int r) { while (l < r) { int 阅读全文
posted @ 2020-02-18 16:28 想拿牌想考研的菜鸡 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 归并排序其实也是分治的思想 首先归并排序跟快排一样同样需要考虑分界点 归并排序的分界点都是取中间值 其次归并排序需要递归排序左边和右边 最后一部也是最难的一部需要将分开的归并排序合二为一 #include<iostream> using namespace std; int n; const int 阅读全文
posted @ 2020-02-18 02:41 想拿牌想考研的菜鸡 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 首先快速排序分为三部 首先要先确定分界点x = a[l] a[r] a[(l+r)/2]都行依据情况而定 其次 调整区间,定义双指针的方法,排序一次后,i指针前面的数一定小于等于x(分界点)j指针后面的数一定大于等于x 最后递归完成排序 #include <iostream>#include <st 阅读全文
posted @ 2020-02-17 18:16 想拿牌想考研的菜鸡 阅读(177) 评论(0) 推荐(0) 编辑