摘要: 掉大分补提 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 阅读全文
posted @ 2023-03-27 12:20 xxj112 阅读(48) 评论(0) 推荐(0)
摘要: 原理: 题解在代码里,如下 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int,int> PLL; #define IOS cin.tie(nullptr)->sync_ 阅读全文
posted @ 2023-03-27 11:47 xxj112 阅读(47) 评论(0) 推荐(0)
摘要: 拓扑排序的核心就是 找入度为零的点,然后把于该点相连接的边去掉,同时更新剩余点的入度,由于n可能很大,需要邻接表,(这里用vector模拟),也可以学习链式向前星。 点击查看代码 #include <bits/stdc++.h> using namespace std; const int N=1e 阅读全文
posted @ 2023-03-10 17:13 xxj112 阅读(25) 评论(0) 推荐(0)
摘要: 点击查看代码 #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) { 阅读全文
posted @ 2023-03-04 10:28 xxj112 阅读(33) 评论(0) 推荐(0)
摘要: 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 阅读全文
posted @ 2023-03-03 18:29 xxj112 阅读(20) 评论(0) 推荐(0)
摘要: 思路:一定能拆成 x1的二次方,x2的三次方。当把数分解成质因数乘积后,如果有单独的质数,一定不合理, 也就是说如果有质因数,每种质因数最低有两个 ,从而如果同意质因数大于2且为偶数 ,就可以合成两个荷和数,放x1中,如果为奇数,先拿出三个,放入x2中,剩下的放入x1中。 这里需要用质数筛预处理40 阅读全文
posted @ 2023-03-01 18:32 xxj112 阅读(64) 评论(0) 推荐(0)
摘要: 思路:利用线段树求出 a[i] (以 下表i所在数为结尾的最长不下降序列), 然后刷新线段树,从大到小 重新放入线段树 ,求出 区间 (i+k+1~n)之间 最大的不下降子序列。 代码 点击查看代码 #include<bits/stdc++.h> using namespace std; const 阅读全文
posted @ 2023-03-01 18:03 xxj112 阅读(25) 评论(0) 推荐(0)
摘要: 当前数组 a1 a2 a3.....an; 对于每个下表i,求 aj<ai ( j<i ) 的个数,为当ai的文化素养, 点击查看代码 #include<bits/stdc++.h> using namespace std; const int N=1e7+9; int e[N],a[N],lazy 阅读全文
posted @ 2023-02-25 08:43 xxj112 阅读(20) 评论(0) 推荐(0)
摘要: 当你在代码中写下 ios::sync_with_stdio(0); cin.tie(0); 的时候( 关闭流同步),终于实现了cin的快速输入,但是这也意味着你与cin,cout终身绑定,白头偕老,画上完美句号(程序结束)。 如果你用的是dev编辑器,有可能你的数据依然对,请不要疑惑,这只是编辑器的 阅读全文
posted @ 2023-02-21 21:56 xxj112 阅读(50) 评论(0) 推荐(0)
摘要: 版本一:1e7内比欧拉筛子快一倍,2e7持平,之后略慢 不论N多大整体计算次数,都是欧拉筛子的1/3,求大神解答1e8之后为什么变慢 思路:相较于欧拉筛考虑1-n所有数,这里基于孪生素数,只需要考虑孪生素数,n/3; 版本二:解决了1e8的问题,多加了一个sqrt(N)的处理,缺点代码更繁琐。 版本 阅读全文
posted @ 2023-02-20 21:52 xxj112 阅读(70) 评论(0) 推荐(0)