摘要: 基础数论: 质数(一般用线性筛) 约数 快速幂 组合数 容斥 补题: C - Bacteria 救命,取栈顶元素没开long long,太可惜了 #include <bits/stdc++.h> using namespace std; typedef long long ll; const int 阅读全文
posted @ 2022-07-09 08:39 好腻友Π 阅读(19) 评论(0) 推荐(0)
摘要: 基础算法: 二分 #include <bits/stdc++.h> using namespace std; #define int long long const int N = 2e5 + 10; int n, m; int a[N], b[N]; bool check(int x) { int 阅读全文
posted @ 2022-07-08 10:30 好腻友Π 阅读(18) 评论(0) 推荐(0)
摘要: 贪心DP CF题选讲 二叉树 阅读全文
posted @ 2022-07-08 10:28 好腻友Π 阅读(11) 评论(0) 推荐(0)
摘要: dfs(尽可能往深搜)栈O(n) 顺序+剪枝 全排列 #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N=10; int path[N]; bool st[N]; int n; void df 阅读全文
posted @ 2022-07-07 10:38 好腻友Π 阅读(23) 评论(0) 推荐(0)
摘要: 单调栈 GInger的神罚洛谷U220471 #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int>pii; const int N=2e5+10; ll a[N],dp[N] 阅读全文
posted @ 2022-07-05 10:32 好腻友Π 阅读(19) 评论(0) 推荐(0)
摘要: E ginger的染色 首先对于一个排列 ,如果看成环图的结构,那么 就向 连一条无向边。所以对于任意一个排列就会产生若干个环,连通性可以用并查集维护,现在对每个点进行黑白染色,题意转换为对于环中任意相邻两点颜色不能相同,那么只有偶数元环才能够染色成二分图,而每个偶环的方案数为 ,设当前有 个环,总 阅读全文
posted @ 2022-06-21 21:29 好腻友Π 阅读(28) 评论(0) 推荐(0)
摘要: 个人赛-1 Magical Bamboos 思路:从大到小排序,然后从头到尾遍历,每相邻两个数相差为偶数,则这两个数可以都变成他俩的平均数,对后面的数包括这两个数的后一个数他们相当于都增加了一个值,但这并不改变原本两两之间的差值。因此如果两两之间差值都为偶数,则可以变成同一个值。 Make Cent 阅读全文
posted @ 2022-06-20 20:55 好腻友Π 阅读(23) 评论(0) 推荐(0)
摘要: islands dfs #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N=55; char a[N][N]; int n,m,res; int dx[4]= {-1,0,1,0}; int 阅读全文
posted @ 2022-06-17 21:21 好腻友Π 阅读(17) 评论(0) 推荐(0)
摘要: bookshelf filling 二分,从右边的长度为b的书中选tt本,看上面剩下的空间能否摆下tt本。因为tt的值越小,越有可能摆下,所以满足二分的性质。 #include <bits/stdc++.h> using namespace std; typedef long long ll; co 阅读全文
posted @ 2022-06-10 20:12 好腻友Π 阅读(59) 评论(0) 推荐(0)
摘要: B #include <iostream> #include <algorithm> #include <cstring> #include <math.h> using namespace std; typedef long long ll; const int N=1e3+10; char s[ 阅读全文
posted @ 2022-06-01 08:47 好腻友Π 阅读(23) 评论(0) 推荐(0)