![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
蓝桥杯学习
文章平均质量分 50
兴安仓鼠
LEARN BY DOING!
展开
-
专题六——复杂DP
1.1050.鸣人的影分身 状态表示:f(i,j):所有总和是i且分成j个数的总方案 状态计算:分成两个集合:最小值是0:f(i,j-1);最小值不是0::让每个方案里面的数减一:f(i-j,j) f(i,j)=f(i,j-1)+f(i-j,j) #include <bits/stdc++.h> using namespace std; const int N=11; int f[N][N]; int main() { int T; scanf("%d",&T);原创 2021-02-20 11:20:58 · 196 阅读 · 0 评论 -
专题五——数论应用
1.1246.等差数列 欧几里得算法应用 #include <bits/stdc++.h> using namespace std; const int N=100010; int a[N]; int gcd(int a,int b) { return b?gcd(b,a%b):a; } int main() { int n; scanf("%d",&n); for(int i=0;i<n;i++) scanf("%d",&a[i]);原创 2021-02-18 12:43:19 · 235 阅读 · 0 评论 -
专题四——线段树、树状数组
树状数组:快速求前缀和 O(logn) 两种基本操作: ①给某个位置上的数加上一个数 ②求某一个前缀和 1.1264. 动态求连续区间和【三个模板要记住】 #include <bits/stdc++.h> using namespace std; const int N=100010; int n,m; int a[N],tr[N]; int lowbit(int x) { return x&-x; } void add(int x,int v) { for(int原创 2021-02-14 12:06:43 · 125 阅读 · 0 评论 -
专题三——枚举、模拟、排序
1.1236. 递增三元组 方法一:二分要在ac两个数组中找严格小于或大于b[i]的第一个位置【经过我与大佬的苦苦钻研才改好/(ㄒoㄒ)/~~】 #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N=100010; ll a[N],b[N],c[N]; ll ax[N],cx[N]; ll cnt[N],s[N]; ll n; ll finda(ll a[],ll u) { ll原创 2021-02-10 14:10:53 · 156 阅读 · 0 评论 -
专题二——数学问题与简单DP
1.买不到的数目 记住公式即可 #include <bits/stdc++.h> using namespace std; int main() { int p,q; cin>>p>>q; printf("%d\n",p*q-q-p); return 0; } 2.蚂蚁感冒 分情况讨论,最终代码可以合二为一的写 #include <bits/stdc++.h> using namespace std; const in原创 2021-02-08 14:01:24 · 169 阅读 · 0 评论 -
专题一——递归与递推
1. 92.递归实现指数型枚举 时间复杂度:O(n*2n2^n2n) #include <bits/stdc++.h> using namespace std; const int N=16; int n; int st[N]; void dfs(int u)//u表示当前在做第几位 { if(u>n) { for(int i=1;i<=n;i++) if(st[i]==1) printf("%d ",i);原创 2021-02-05 13:39:44 · 118 阅读 · 0 评论