思路: 水题,略过 Tip: 无 #include <bits/stdc++.h> using namespace std; const int maxn = 1000 + 5; queue<char> que[maxn]; stack<char> s; int main() { int n, m, ...
分类:
其他好文 时间:
2021-04-27 15:08:37
阅读次数:
0
#include <bits/stdc++.h> typedef unsigned long long ll; const ll P=1331; using namespace std; ll hash1[1000000],u[1000000]; ll get(int l,int r){ retur ...
分类:
其他好文 时间:
2021-04-27 15:00:27
阅读次数:
0
今天我来分享一下如何利用素数分解定理求解与n互质的数的个数。 下面是代码 #include<bits/stdc++.h> using namespace std; long long fun(int x) { long long ans=x; int t=sqrt(x); int cnt; for( ...
分类:
其他好文 时间:
2021-04-26 14:12:06
阅读次数:
0
问题 在一堆数组当中,选出第k小的数组 分析 在一般的情况下面,要选择第k小的数组,要先给它进行排序,排序至少需要O(n * logn)的时间复杂度,但是我们可以用分治的思想,相当于快排,给它进行分组,一组一组的进行排序,虽然也是排序,但是时间复杂度可以到达O(n)。 #include<bits/s ...
分类:
其他好文 时间:
2021-04-26 13:22:43
阅读次数:
0
转化题目,题目要求的是K级祖先,我们可以对于每个询问先跳到祖先,那么就是求对于这个祖先,depth[u]+k的个数是多少个,然后-1就是答案 #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair ...
分类:
其他好文 时间:
2021-04-24 13:41:24
阅读次数:
0
链接:https://pintia.cn/problem-sets/994805046380707840/problems/1336215880692482060 思路: 代码: #include<bits/stdc++.h> using namespace std; vector<int>ve[1 ...
分类:
其他好文 时间:
2021-04-24 13:26:55
阅读次数:
0
做法:记录每个点i向左与它最近的不互质的数j,从j+1到i是可以分成1块的。 对于每次询问,从r开始一直贪心往前跳,每跳一步ans++;但这样一步一步跳会T,需要去倍增优化。 #include<bits/stdc++.h> using namespace std; #define ll long l ...
分类:
其他好文 时间:
2021-04-23 12:09:38
阅读次数:
0
1. 用union结构区分大小端 #define read_bits(stc, field)({stc.raw = 0x12345678; stc.bits.field;}) union a{ unsigned int raw; struct { unsigned int bit_a : 8; un ...
分类:
其他好文 时间:
2021-04-23 12:09:11
阅读次数:
0
题目大意 给一个二叉树的中序遍历和前序遍历,求其镜像后的层序遍历 类似于 L2-006 树的遍历 (25 分) 建树 镜像就在dfs的时候先输出右子树 再 左子树 #include<bits/stdc++.h> using namespace std; struct node { int l,r; ...
分类:
其他好文 时间:
2021-04-21 12:12:05
阅读次数:
0
爆搜,按照题意来搜。。。 太难写了,当模拟写的,代码分成了很多块,长度比较难看。。。 #include<bits/stdc++.h> using namespace std; #define ll long long #define fastio ios::sync_with_stdio(false ...
分类:
其他好文 时间:
2021-04-20 15:37:24
阅读次数:
0