随笔分类 - 模板
摘要:ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
阅读全文
摘要:555搞了这么久算法居然才学扫描线...... 愧疚愧疚 扫描线也不算是一种算法,实际上是一种技♂巧。 在处理矩形覆盖类的问题(目前只做了矩形覆盖hhh)时,我们将每个矩形的上下两条底边存储,记录左、右的坐标以及它距离x轴的高度h,同时定义一个标记tag为1/-1来表明它是上底边还是下底边。 与此同
阅读全文
摘要:异或前缀和 进位加法与不进位加法 a + b = (a ⊕ b) + 2 ∗ (a & b) 01字典树 a ^ b > max(a, b) * 2
阅读全文
摘要:基本操作: 1 #include<iostream> 2 #include<unordered_set> 3 using namespace std; 4 5 unordered_set<int> s; 6 7 int main(){ 8 int n = 10; 9 for(int i = 1 ;
阅读全文
摘要:1 #include<iostream> 2 #include<cstring> 3 #include<string> 4 #include<cmath> 5 #include<cstdio> 6 #include<queue> 7 #define ll long long 8 #define IN
阅读全文
摘要:1 int maxsub = sum = 0; 2 for(int i = 1 ; i <= n ; i++){ 3 sum += a[i]; 4 if(sum > maxsub) maxsub = sum; 5 if(sum < 0) sum = 0; 6 } 7 8 //res = maxsub
阅读全文
摘要:1 int read(){ 2 char ch=getchar();int x=0,f=1; 3 while(ch<'0' || ch>'9') {if(ch=='-')f=-1;ch=getchar();} 4 while(ch>='0' && ch<='9'){x=x*10+ch-'0';ch=
阅读全文
摘要:1 vector<int> v; 2 v.clear(); 3 vector<int>::iterator it; 4 for(int j = l + 1 ; j < r ; j++){ 5 if(a[j] >= a[l] && a[j] <= a[r]){ 6 it = upper_bound(v
阅读全文
摘要:思想类似前缀和,访问某状态的线段树可通过末减初状态进行求解。 hdu4417 第二道模板题 有很多细节需要注意。 1.题目给定ai的高度可能为0,但通过离散化事实上不影响结论。 2.给定的访问区间[x,y]以及高度h也可能为零,因而x,y需对应++。查询依旧是root[y] - root[x-1]。
阅读全文
摘要:https://www.acwing.com/blog/content/31/ 服了 每次有二分的题总归写错... 小本本上记好! 1 int l = 0, r = mx; 2 while(l < r){ 3 int mid = (l + r) >> 1; 4 if(check(mid)){ 5 l
阅读全文
摘要:1 #include<bits/stdc++.h> 2 using namespace std; 3 4 const int maxn = 5e4 + 10; 5 6 int n; 7 8 int vis[maxn];//最小质因子 9 int prime[maxn]; 10 int fun[max
阅读全文
摘要:1 #include<iostream> 2 #include<algorithm> 3 #include<cstring> 4 #include<cmath> 5 #include<cstdio> 6 7 using namespace std; 8 9 const int maxn = 2e5
阅读全文
摘要:转自:https://blog.csdn.net/weixin_43914593/article/details/107508909?utm_source=app 1 import java.math.*; 2 import java.util.*; 3 public class Main{ 4 p
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6869 威佐夫博弈原本是每次操作任取某堆的任意个石头1,或是从两堆中分别取出相同数量的石头2 方程为: 1 / t + 1 / t + 1 = 1; 当操作2修改为取出石头数量之差不超过k,即本题含义时,
阅读全文

浙公网安备 33010602011771号