摘要: 二维前缀和 原数组a[i][j] 前缀和数组s[i][j]表示i,j这个点左上角所有数的和 所以以x1,y1为左上角,x2,y2为右下角的矩阵的和等于:上式。 这是计算子矩阵的和。 然后是如何初始化前缀和数组。 1 #include <bits/stdc++.h> 2 using namespace 阅读全文
posted @ 2020-06-28 20:12 kyk333 阅读(387) 评论(0) 推荐(0)
摘要: 前缀和里,下标从1开始。 原数组为a[1],a[2],a[3],...,a[n]。 前缀和数组s[i]表示原数组中前i个数的和。s[i] = a[1] + a[2] + ... + a[i]。 前缀和数组是由原数组计算出来的。 1:如何求s[i]: 从前往后递推一遍就好了 s[0] = 0 2:前缀 阅读全文
posted @ 2020-06-28 19:28 kyk333 阅读(179) 评论(0) 推荐(0)
摘要: 大数除以一个小数 1 #include <bits/stdc++.h> 2 using namespace std; 3 //A/b商是C,余数是r 4 vector<int> div(vector<int> &A, int b, int &r) { 5 vector<int> C; 6 r = 0 阅读全文
posted @ 2020-06-28 18:23 kyk333 阅读(199) 评论(0) 推荐(0)
摘要: 不用保证A>=B 大数乘小数 这里是把小数b当成一个整体来乘。 1 #include <bits/stdc++.h> 2 using namespace std; 3 vector<int> mul(vector<int> &A, int b) { 4 vector<int> C; 5 int t 阅读全文
posted @ 2020-06-28 17:50 kyk333 阅读(209) 评论(0) 推荐(0)
摘要: 假定A和B都是正数,假定A这个数>=B这个数。 1 #include <bits/stdc++.h> 2 using namespace std; 3 bool cmp(vector<int> &A, vector<int> &B) { //判断是否A>=B,如果A>=B返回true,否则返回fal 阅读全文
posted @ 2020-06-28 16:14 kyk333 阅读(178) 评论(0) 推荐(0)
摘要: 1 #include <bits/stdc++.h> 2 using namespace std; 3 vector<int> add(vector<int> &A, vector<int> &B) { //加上引用,不然很慢 4 vector<int> C; //答案 5 int t = 0; / 阅读全文
posted @ 2020-06-28 15:21 kyk333 阅读(189) 评论(0) 推荐(0)