03 2023 档案
C - 素数密度
摘要:题解在代码里,如下 点击查看代码 #include<bits/stdc++.h> typedef long long LL; using namespace std; //如果一个数n不是质数,就一定有非一的因数x<=sqrt(n); const int N=5e4; //因为所给题目最大到(1<<
哈希表
摘要:点击查看代码 using namespace std; typedef long long LL; typedef pair<string,int> PLL; #define IOS cin.tie(nullptr)->sync_with_stdio(false); #define se secon
CF:D. Shocking Arrangement
摘要:掉大分补提 D 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int,int> PLL; #define IOS cin.tie(nullptr)->sync_with_s
骏码杯I题:最大公约数求和
摘要:原理: 题解在代码里,如下 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int,int> PLL; #define IOS cin.tie(nullptr)->sync_
拓扑排序
摘要:拓扑排序的核心就是 找入度为零的点,然后把于该点相连接的边去掉,同时更新剩余点的入度,由于n可能很大,需要邻接表,(这里用vector模拟),也可以学习链式向前星。 点击查看代码 #include <bits/stdc++.h> using namespace std; const int N=1e
蓝桥杯 & 青蛙过河(最快贪心) (不用并查集)
摘要:点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=1000000+7; ll a[N]; ll b[N]; ll c[N]; ll n,x; bool check(ll w) {
map运用
摘要:map 可以自动排序 ,第一个为最小值 ,返回最大值的时候时间复杂度为log(n) 点击查看代码 #include<bits/stdc++.h> using namespace std; int main() { int n=10; map<int,int> ma; for(int i=1;i<=n
数的拆分
摘要:思路:一定能拆成 x1的二次方,x2的三次方。当把数分解成质因数乘积后,如果有单独的质数,一定不合理, 也就是说如果有质因数,每种质因数最低有两个 ,从而如果同意质因数大于2且为偶数 ,就可以合成两个荷和数,放x1中,如果为奇数,先拿出三个,放入x2中,剩下的放入x1中。 这里需要用质数筛预处理40
最长不下降子序列
摘要:思路:利用线段树求出 a[i] (以 下表i所在数为结尾的最长不下降序列), 然后刷新线段树,从大到小 重新放入线段树 ,求出 区间 (i+k+1~n)之间 最大的不下降子序列。 代码 点击查看代码 #include<bits/stdc++.h> using namespace std; const