上一页 1 2 3 4 5 6 7 ··· 10 下一页
摘要: #include <iostream> #include <cstring> #include <algorithm> using namespace std; const int N = 505; int dis[N],w[N]; bool visit[N]; int e[N][N],weight 阅读全文
posted @ 2022-04-16 23:19 秋月桐 阅读(15) 评论(0) 推荐(0) 编辑
摘要: #include<bits/stdc++.h> using namespace std; float c[1001]; int main(){ int k1,k2; cin>>k1; for(int i=1;i<=k1;i++){ float b; int a; cin>>a>>b; c[a]+=b 阅读全文
posted @ 2022-04-16 23:18 秋月桐 阅读(17) 评论(0) 推荐(0) 编辑
摘要: #include<bits/stdc++.h> using namespace std; int main(){ int a,b; cin>>a>>b; int res=a+b; string s=to_string(res); int cnt=1; for(int i=s.size()-1;i>= 阅读全文
posted @ 2022-04-16 23:17 秋月桐 阅读(13) 评论(0) 推荐(0) 编辑
摘要: 时间复杂度:logn 树状数组的唯一作用:快速求前缀和并支持单点修改(增加一个数,或者加当前数相反数,再加自己想修改的数,实现数值替换) 区间修改,单点查询题 需要将原题目差分 区间修改,区间查询。 树状数组公式(最好记忆): C[x]=(x-lowbit(x),x] 区间内数的和 lowbit(x 阅读全文
posted @ 2022-03-29 19:09 秋月桐 阅读(21) 评论(0) 推荐(0) 编辑
摘要: 滑动窗口问题。 寻找最大长度的窗口,窗口内 'T' 或 'F'的数量为k class Solution { public: string s; int n; int gk; int getCnt(char c){ int ans=0; int j=0,cnt=0; for(int i=0;i<n;i 阅读全文
posted @ 2022-03-29 19:04 秋月桐 阅读(16) 评论(0) 推荐(0) 编辑
摘要: 蓝桥杯--杨辉三角形 核心:求组合数的方法,找规律 https://www.acwing.com/problem/content/3421/ #include <iostream> #include <cstring> #include <algorithm> using namespace std 阅读全文
posted @ 2022-03-16 15:05 秋月桐 阅读(78) 评论(0) 推荐(0) 编辑
摘要: 题目:蓝桥杯 --完全平方数 https://www.acwing.com/problem/content/3494/ 一个平方数的本质是成偶数对个的质因子的乘积,不可能存在奇数个质因子 #include<bits/stdc++.h> using namespace std; typedef lon 阅读全文
posted @ 2022-03-15 20:36 秋月桐 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 二叉树遍历的升级 >对于n叉树遍历,利用栈的处理以及对孩子结点的处理值得注意 https://leetcode-cn.com/problems/n-ary-tree-postorder-traversal/ 后序遍历,迭代方式: class Solution { public: vector<int 阅读全文
posted @ 2022-03-15 20:32 秋月桐 阅读(45) 评论(0) 推荐(0) 编辑
摘要: 通过二进制枚举子集。利用一个int 变量,循环自增,就可以得到2^n种状态,具有极高的泛用性。 mask = 1 << n 表示 全选的情况下的mask数值+1 和dfs感觉上差不多,都是一种暴力搜索的方式,但是写法相对简单。 https://leetcode-cn.com/problems/cou 阅读全文
posted @ 2022-03-15 20:27 秋月桐 阅读(58) 评论(0) 推荐(0) 编辑
摘要: 裴蜀定理:任意两个数来组合,必定是其gcd的倍数。 推广:如果求n个数的组合结果集,如果这n个数的gcd不为1,则有无穷个数无法被组合。 gcd=1时,两个数最大不能表示的数是**(a-1)(b-1)-1**; 本题的状态方程和完全背包模板题类似,不过求max变成了 || 。 dp状态表示的是前i类 阅读全文
posted @ 2022-02-27 11:21 秋月桐 阅读(86) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 10 下一页