码迷,mamicode.com
首页 >  
搜索关键字:bits    ( 3873个结果
2021团体程序设计天梯赛 L2-1 包装机
思路: 水题,略过 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
hash
#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互质的数的个数
今天我来分享一下如何利用素数分解定理求解与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小的数组 分析 在一般的情况下面,要选择第k小的数组,要先给它进行排序,排序至少需要O(n * logn)的时间复杂度,但是我们可以用分治的思想,相当于快排,给它进行分组,一组一组的进行排序,虽然也是排序,但是时间复杂度可以到达O(n)。 #include<bits/s ...
分类:其他好文   时间:2021-04-26 13:22:43    阅读次数:0
CF208E Blood Cousins(树上启发式合并)
转化题目,题目要求的是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
天梯赛L3-025 那就别担心了 (30 分)
链接: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
D. Cut(倍增) from Codeforces Round #717 (Div. 2)
做法:记录每个点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
union和bit field巧妙进行寄存器位操作
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-011 玩转二叉树 (25 分)
题目大意 给一个二叉树的中序遍历和前序遍历,求其镜像后的层序遍历 类似于 L2-006 树的遍历 (25 分) 建树 镜像就在dfs的时候先输出右子树 再 左子树 #include<bits/stdc++.h> using namespace std; struct node { int l,r; ...
分类:其他好文   时间:2021-04-21 12:12:05    阅读次数:0
PAT 1022 Werewolf PAT顶级
爆搜,按照题意来搜。。。 太难写了,当模拟写的,代码分成了很多块,长度比较难看。。。 #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
3873条   上一页 1 ... 4 5 6 7 8 ... 388 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!