摘要: 极好的博客讲解 lowbit函数 int lowbit(int x) { return x & (-x); } 修改以及建树的函数 void add(int x, int k) { for (int i = x; i < N; i += lowbit(i))tr[i] += k; } 一点要注意建树 阅读全文
posted @ 2023-07-16 09:00 north_h 阅读(12) 评论(0) 推荐(0)
摘要: 1.加法 string add(string a,string b) { if (a.size() < b.size())swap(a, b); vector<int> A, B, C; for (int i = a.size() - 1; i >= 0; i--)A.push_back(a[i] 阅读全文
posted @ 2023-07-16 09:00 north_h 阅读(26) 评论(0) 推荐(0)
摘要: 传送门 A 函数 注意开long long #pragma GCC optimize(2) #pragma GCC optimize(3) #include<bits/stdc++.h> #define IOS ios::sync_with_stdio(false),cin.tie(nullptr) 阅读全文
posted @ 2023-06-24 09:00 north_h 阅读(20) 评论(0) 推荐(0)
摘要: 传送门 A 简单的整除 #pragma GCC optimize(2) #pragma GCC optimize(3) #include<bits/stdc++.h> #define IOS ios::sync_with_stdio(false),cin.tie(nullptr), cout.tie 阅读全文
posted @ 2023-06-10 09:00 north_h 阅读(30) 评论(0) 推荐(0)
摘要: 通俗易懂的博客 ST表是能够在o(nlgn)的预处理情况下,在o(1)的复杂度情况下来求一段区间的最小值和最大值,可以用来求重复贡献对问题答案没有影响的问题 为了减少时间复杂度,可以先预处理出lg2的数组,就不要每次都去用log函数 lg2[0] = -1 //方便求lg2循环数组 for(int 阅读全文
posted @ 2023-06-09 09:00 north_h 阅读(36) 评论(0) 推荐(0)
摘要: 传送门 A New Palindrome 就判断回文串中出现的字母种类是不是大于1 #include<bits/stdc++.h> //#define int long long #define fi first #define se second using namespace std; cons 阅读全文
posted @ 2023-05-14 09:00 north_h 阅读(14) 评论(0) 推荐(0)
摘要: 传送门 C Darkness I 这个题就是找出一种放最少几个黑块能全部变黑,我么可以沿着对角线放,先以最小的那一边的正方形用对角线的方法放完,然后再两隔一列放一个,但是要注意向上取整。 #include<bits/stdc++.h> #define int long long #define fi 阅读全文
posted @ 2023-05-14 09:00 north_h 阅读(18) 评论(0) 推荐(0)
摘要: 快速幂 利用倍增的思想,将o(n)的时间复杂度优化成o(lgn) int ksm(int x,int y,int p) { int res = 1; while (y) { if (y & 1)res = (res * x) % p; x = (x * x) % p; y = y >> 1; } r 阅读全文
posted @ 2023-05-14 09:00 north_h 阅读(31) 评论(0) 推荐(0)
摘要: 传送门 A. 签到啦 排个序每次选最大的 #include<bits/stdc++.h> #define int long long #define endl '\n' #define fi first #define se second using namespace std; const int 阅读全文
posted @ 2023-05-14 09:00 north_h 阅读(14) 评论(0) 推荐(0)
摘要: 传送门 A Compare T-Shirt Sizes 简单模拟,分情况讨论即可。 #include<bits/stdc++.h> #define int long long using namespace std; const int N = 100010; void solve() { stri 阅读全文
posted @ 2023-05-05 09:00 north_h 阅读(14) 评论(0) 推荐(0)