摘要:
树形DP 首先是树的储存,树的储存是图的储存的特殊情况,可以用邻接表储存,或链式向前星 洛谷P2015二叉苹果树 定义状态dp[u][j]表示以节点u为根的子树上留 j 条边时的最多苹果数量。dp[1][q]就是答案。 状态转移方程:dp[u][j] = max(dp[u][j], dp[u][j- 阅读全文
posted @ 2025-06-14 12:27
HLAIA
阅读(14)
评论(0)
推荐(1)
摘要:
本部蓝桥试炼 续上回 B 线段树板子,但奈何我现在没法手撕线段树哇(码太长了) 遂选择树状数组,但是--按理说树状数组(nlog2n)的复杂度是能过此题的,而且赛后题解里也说了树状数组能过,为什么才拿25分?? (后来发现问题了--忘记取模,唉) 题补就写线段树的吧 #include <bits/s 阅读全文
posted @ 2025-06-14 12:26
HLAIA
阅读(4)
评论(0)
推荐(0)
摘要:
牛客月赛113 A 签到 #include <bits/stdc++.h> using namespace std; int main(void){ ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); int sum = 1; string s; 阅读全文
posted @ 2025-06-14 12:26
HLAIA
阅读(7)
评论(0)
推荐(0)
摘要:
牛客周赛 85 A 签到 #include <bits/stdc++.h> using namespace std; int main(void){ ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); int n; cin >> n; cout 阅读全文
posted @ 2025-06-14 12:25
HLAIA
阅读(4)
评论(0)
推荐(0)
摘要:
牛客周赛86 A 签到 #include <bits/stdc++.h> using namespace std; int main(void){ ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); int x,y; cin >> x >> y; 阅读全文
posted @ 2025-06-14 12:25
HLAIA
阅读(5)
评论(0)
推荐(0)
摘要:
牛客周赛84 续上周 D 赛时用的数学方法,花的时间和代码量比较多。差分我写得少,这里用题解的差分方法补个题 用差分数组对每个k区间做修改,然后求和以及相邻数字绝对值差对陡峭值的贡献即可 #include <bits/stdc++.h> using namespace std; const int 阅读全文
posted @ 2025-06-14 12:24
HLAIA
阅读(6)
评论(0)
推荐(0)
摘要:
牛客月赛 111 A 贪心,田鸡的最大的a比齐威王次大的v大,田鸡的次大的a比齐威王最小的v大就能赢 #include <bits/stdc++.h> using namespace std; int main(void){ ios::sync_with_stdio(false); cin.tie( 阅读全文
posted @ 2025-06-14 12:23
HLAIA
阅读(8)
评论(0)
推荐(0)
摘要:
牛客周赛81 A 题目 签到 代码 #include <bits/stdc++.h> using namespace std; int main(void){ ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); int a,b,c; cin >> 阅读全文
posted @ 2025-06-14 12:23
HLAIA
阅读(11)
评论(0)
推荐(0)
摘要:
牛客周赛80 A 题目 签到 代码 #include <bits/stdc++.h> using namespace std; int main(void){ ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); int x,y; cin >> x 阅读全文
posted @ 2025-06-14 12:22
HLAIA
阅读(7)
评论(0)
推荐(0)
摘要:
牛客寒假训练营1 大家都报了训练营呐,那我也报一个 v(虽晚不亏) 补一下之前的 A 题目 这题考察素数。由题目得,ai不超过1e9,因此如果给的数有1就输入-1(1和任何数都构成倍数关系),否则输出任意一个比1e9大的素数、 那比1e9大的素数怎么找呢? 新开一个cpp,用埃氏筛把这个数找到,是9 阅读全文
posted @ 2025-06-14 12:21
HLAIA
阅读(8)
评论(0)
推荐(0)

浙公网安备 33010602011771号