摘要: int findMinValid(int left, int right) { int ans = -1; while (left <= right) { int mid = (left+right)/2; if (check(mid)) { // 满足条件,尝试找更小的解 ans = mid; / 阅读全文
posted @ 2025-10-03 20:58 wtnbl 阅读(1) 评论(0) 推荐(0)
摘要: 少使用rbegin,用prev(end()) 尽量使用容器自带的函数,比如set的lower_bound() 阅读全文
posted @ 2025-09-24 15:01 wtnbl 阅读(3) 评论(0) 推荐(0)
摘要: 可以用一个map数组记录边存了没有 最简单好写的 数据范围\(m<=5e4\) map<pair<int,int>,bool> uni; for(int u,v,i=1;i<=m;i++) { cin>>u>>v; if(uni[{u,v}]) continue; uni[{u,v}]=uni[{v 阅读全文
posted @ 2025-08-28 10:10 wtnbl 阅读(4) 评论(0) 推荐(0)
摘要: 求强联通分量 解释见代码 #include <bits/stdc++.h> using namespace std; const int N = 100005; // 根据题目最大点数修改 int n, m; vector<int> G[N]; int dfn[N]/*时间戳,代表u的访问顺序*/, 阅读全文
posted @ 2025-08-27 16:33 wtnbl 阅读(3) 评论(0) 推荐(0)
摘要: 卢卡斯定理 对于素数 p,有 \(\binom{n}{k}\equiv \binom{\lfloor n/p\rfloor}{\lfloor k/p\rfloor}\binom{n\bmod p}{k\bmod p}\pmod p.\) 其中,当 n<k 时,二项式系数 \(\dbinom{n}{k 阅读全文
posted @ 2025-08-26 22:37 wtnbl 阅读(4) 评论(0) 推荐(0)
摘要: #include <bits/stdc++.h> #define lson l,m,k*2 #define rson m+1,r,k*2+1 //左右儿子在函数里面用 #define int long long using namespace std; const int N=5000005; in 阅读全文
posted @ 2025-08-26 22:33 wtnbl 阅读(6) 评论(0) 推荐(0)