小男娘
小男娘
全部文章
分类
题解(2)
归档
标签
去牛客网
登录
/
注册
小男娘的博客
全部文章
(共31篇)
bitset 优化背包判断
使用 bitset 优化背包判断,时间复杂度 #include <bitset> #include <iostream> using namespace std; int n; int k; bitset<1001> have = 1; void Solve(...
2025-11-28
0
10
大炮打蚊子:折半搜索
枚举前半子集存哈希表,枚举后半子集查哈希表此做法可过 #include <iostream> #include <vector> #include <unordered_map> using namespace std; int n; int k; vector...
2025-11-28
0
13
题解 | 【模板】点圆位置关系
难点只有第三问。算出夹角余弦值,然后换算出夹角正弦值,按虚数乘法旋转半径向量即可。 #include <cfloat> #include <cmath> #include <iomanip> #include <iostream> #include &...
2025-11-27
0
14
题解 | 【模板】点线位置关系
用判断点的位置,若为正则在左侧,若为负则在右侧,若为零,继续判断,若则 C 在 AB 上。 #include <iostream> using namespace std; using ll = long long; struct Point { ll x; ll y...
2025-11-27
0
12
题解 | 【模板】高精度加法
直接在字符串上操作即可。倒序方便进位。 #include <algorithm> #include <iostream> using namespace std; string a; string b; int main() { ios::sync_with_st...
2025-11-27
0
12
题解 | honoka和格点三角形
显然答案为。 #include <iostream> using namespace std; using ll = long long; const int MOD = 1e9 + 7; ll n; ll m; int main() { ios::sync_with_s...
2025-11-27
0
13
题解 | 小红的排列构造
显然排列构成若干个非自环环故无解,其它情况先构造一个大小为的环,剩下全构造大小为的环即可。 #include <iostream> using namespace std; int n; int k; int main() { ios::sync_with_stdio(fal...
2025-11-27
0
13
符合题目要求的 O(1) 算法
无力吐槽,翻了前面这么多题解没一个是按照题目要求写算法的,居然运行时间能在 10ms 以内,真是奇迹。维护两个栈,一个维护编号本身,以下称为栈;一个维护编号前缀最小值,以下称为最小栈。于是就可以常数时间实现所有操作了。 class Solution { vector<int> s...
2025-11-26
0
11
题解 | Capslock
两个简化代码的方式:可以检测除了首字母以外是否有小写字母,如果没有,则选择翻转;对字符异或 32 就可以转换大小写,无需分类讨论 #include <cctype> #include <iostream> using namespace std; string s; vo...
2025-11-26
0
6
题解 | 隔板与水槽
发现,于是可以对于每个中间隔板分别枚举左右水槽的最大值,加起来再求最大值即可。时间复杂度。 #include <iostream> #include <vector> using namespace std; using ll = long long; int n; v...
2025-11-25
0
7
首页
上一页
1
2
3
4
下一页
末页