摘要: CF Problem - 362C - Codeforces 前缀和 前缀和计算区间逆序对数(cut*2+1,注意还包括边界) pre[i][v]:前 i 个元素中,小于等于 v 的元素数量 枚举交换的逆序对,统计两数之间的中间值个数,从而计算最多能减少多少逆序对。 #include <bits/s 阅读全文
posted @ 2026-07-21 21:55 Seren_blingbling 阅读(9) 评论(0) 推荐(0)
摘要: CF Problem - 1794D - Codeforces 数学推导,方案数dp dp[j]: 从已经处理过的不同质数中选择 j 个, 所有选择集合的 cnt 乘积之和。 ![[Pasted image 20260720162635.png|400]] cnt[x] 是对剩余指数排列数的修正,不 阅读全文
posted @ 2026-07-20 19:38 Seren_blingbling 阅读(10) 评论(0) 推荐(0)
摘要: CF Problem - 1060E - Codeforces 树上问题 对于原先的树,在为所有有共同邻居的地铁站对新建隧道后,两点之间的路径缩短到原来1/2上取整 所以计算所有点对之间的距离,通过算每条边可能被多少点经过,\(O(n)\) 然后除以二,就得到缩短路径和 但是奇数距离要额外考虑 可以 阅读全文
posted @ 2026-06-17 10:34 Seren_blingbling 阅读(12) 评论(0) 推荐(0)
摘要: CF Problem - 1329B - Codeforces 异或好题 按数字最高位分层 [1] [2,3] [4~7] [8~15] 1 2 4 8 对于 \(a_i\) 只可能是选一层,然后下一次必须选后面的某一层 总之,选或不选,计算方案数 #include <bits/stdc++.h> 阅读全文
posted @ 2026-06-14 11:50 Seren_blingbling 阅读(11) 评论(0) 推荐(0)
摘要: CF Problem - 296B - Codeforces dp好题,通过状态统计方案数 #include <bits/stdc++.h> using namespace std; #define LL long long //#define double long double #define 阅读全文
posted @ 2026-06-13 10:50 Seren_blingbling 阅读(8) 评论(0) 推荐(0)
摘要: CF Problem - 1200D - Codeforces 暴力,前缀和 #include <bits/stdc++.h> using namespace std; #define LL long long //#define double long double #define endl '\ 阅读全文
posted @ 2026-06-12 11:03 Seren_blingbling 阅读(11) 评论(0) 推荐(0)
摘要: CF Problem - 917A - Codeforces 贪心,带一点点反悔 #include <bits/stdc++.h> using namespace std; #define LL long long //#define double long double #define endl 阅读全文
posted @ 2026-06-11 11:39 Seren_blingbling 阅读(11) 评论(0) 推荐(0)
摘要: CF Problem - 1725M - Codeforces 分层图(双层图) #include <bits/stdc++.h> using namespace std; #define LL long long //#define double long double #define endl 阅读全文
posted @ 2026-06-10 10:56 Seren_blingbling 阅读(7) 评论(0) 推荐(0)
摘要: CF Problem - 568B - Codeforces 离散数学学的全忘了啊。。。 二元关系:对集合 \(A = \{1,2,3\}\) 上的二元关系 \(R\): \(R\) 是若干个有序对 \((x,y)\) 的集合。 自环:如果集合里只出现了 (1,1),但没有 (2,2) 或 (3,3 阅读全文
posted @ 2026-06-08 10:06 Seren_blingbling 阅读(12) 评论(0) 推荐(0)
摘要: CF Problem - 274B - Codeforces 树形dp好题 对于必须找含有1的子树,可以从底到顶处理,先满足子节点,然后父节点可以额外和1节点处理 #include <bits/stdc++.h> using namespace std; #define LL long long / 阅读全文
posted @ 2026-06-07 11:28 Seren_blingbling 阅读(15) 评论(0) 推荐(0)