随笔分类 - 算法刷题
摘要:样例题目:按位与结果大于零的最长组合 //计算从低到高第K个二进制位数值位1的元素个数 public int maxlen(int[] candidates, int k) { int res = 0; for (int num : candidates) { //(1 << k)只有指定来判断nu
阅读全文
摘要:题目链接:区间更新 代码 #include<iostream> using namespace std; const int N = 1e5 + 5; int a[N], b[N]; int main() { int n, m; while (cin >> n >> m) { for (int i
阅读全文
摘要:题目链接:统计子矩阵 代码 #include<iostream> using namespace std; const int N = 505; int num[N][N]; int main() { int n, m, k; cin >> n >> m >> k; int count = 0; f
阅读全文
摘要:今天学到一个求质数简单易懂的算法,效率也很高的求职质数算法,开一个数组,从前往后遍历,如果没有被标记证明是质数,没错找到一个质数就被该质数的倍数标记排除,最后得到的数组就是质数了,代码如下 #include <iostream> #include <cmath> #include <vector>
阅读全文

浙公网安备 33010602011771号