上一页 1 2 3 4 5 6 7 8 9 ··· 19 下一页
摘要: #include <iostream> #include <stdio.h> #include <algorithm> #include <string> #define For(i, j, n) for(int i = j ; i <= n ; ++i) using namespace std; 阅读全文
posted @ 2024-03-05 15:33 Gold_stein 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 做这道题的时候混淆了满二叉树和完全二叉树的概念: 满二叉树:顾名思义,就是塞满了 完全二叉树:除了最后一层之外,每一层都必须是满的,且最后一层如果不满,则所有节点都尽可能靠左。 #include <iostream> #include <stdio.h> #include <algorithm> # 阅读全文
posted @ 2024-03-04 12:17 Gold_stein 阅读(9) 评论(0) 推荐(0) 编辑
摘要: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <vector> using namespace std; const int N = 100010; int n; stru 阅读全文
posted @ 2024-03-04 11:17 Gold_stein 阅读(2) 评论(0) 推荐(0) 编辑
摘要: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; typedef long long LL; const int N = 500010; int n, 阅读全文
posted @ 2024-03-04 10:53 Gold_stein 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 暴力秒了 #include<bits/stdc++.h> #define int long long//开long long是个好习惯 using namespace std; bool baozi(int x) { while(x) { int t = x % 10; if(t == 2 || t 阅读全文
posted @ 2024-03-01 23:32 Gold_stein 阅读(6) 评论(0) 推荐(0) 编辑
摘要: 这道题线段树要维护的信息较多,我们在设计线段树存储的信息时,如果发现父节点的信息不能由字节的信息更新而来,而是需要从原数组中获取信息,那么就需要多设计线段树的成员变量,只掉其内部能够自洽,形成闭环为止。 这道题pushup函数的设计非常巧妙,即能够维护线段树,也可以用于处理询问,可以重点记忆学习。 阅读全文
posted @ 2024-02-29 16:55 Gold_stein 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 线段树板子题。 #include <iostream> #include <stdio.h> #include <algorithm> #include <string> #define For(i, j, n) for(int i = j ; i <= n ; ++i) using namespa 阅读全文
posted @ 2024-02-29 09:08 Gold_stein 阅读(1) 评论(0) 推荐(0) 编辑
摘要: tr[i]节点存储的是a[i-lowbit(i)+1]+……+a[i],一共lowbit(i)个数字之和。 query的理解: int query(int k) { int res = 0; for (int i = k; i; i -= lowbit(i)) res += tr[i]; retur 阅读全文
posted @ 2024-02-28 20:41 Gold_stein 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 题解参考AcWing 244. 谜一样的牛 - AcWing 另外,起初我以为是要对身高数组直接建立树状数组来求解问题,但是这样做的信息太少,根本不能得到答案; 实际上,树状数组是用来辅助我们求身高的,我们需要构造一个树状数组,来帮助我们确认牛的身高。 很多数据结构类的问题也是这样,不直接对所求问题 阅读全文
posted @ 2024-02-28 16:29 Gold_stein 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 这道题有两个需要注意的点: 1.两个1e9量级的数字的比值,用double的精度是不够的,要用long double 2.这道题需要输出数学意义上取模的值,需要(ans+mod)%mod转化成正数 这道题测试点巨多,有整整四十个 #include <iostream> #include <stdio 阅读全文
posted @ 2024-02-26 11:51 Gold_stein 阅读(2) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 19 下一页