@@ -77,6 +77,7 @@ https://codeforces.com/problemset/problem/1296/C
77
77
前后缀分解
78
78
- [42. 接雨水](https://leetcode.cn/problems/trapping-rain-water/)([视频讲解](https://www.bilibili.com/video/BV1Qg411q7ia/?t=3m05s))
79
79
- [238. 除自身以外数组的乘积](https://leetcode.cn/problems/product-of-array-except-self/)
80
+ - [2906. 构造乘积矩阵](https://leetcode.cn/problems/construct-product-matrix/)
80
81
- [2256. 最小平均差](https://leetcode.cn/problems/minimum-average-difference/) 1395
81
82
- [2483. 商店的最少代价](https://leetcode.cn/problems/minimum-penalty-for-a-shop/) 1495
82
83
- [2420. 找到所有好下标](https://leetcode.cn/problems/find-all-good-indices/) 1695
@@ -476,15 +477,17 @@ LC936 https://leetcode.cn/problems/stamping-the-sequence/
476
477
LC1199 https://leetcode.cn/problems/minimum-time-to-build-blocks/
477
478
LC2382 https://leetcode.cn/problems/maximum-segment-sum-after-removals/
478
479
LCP52 https://leetcode.cn/problems/QO5KpG/
479
- https://codeforces.com/problemset/problem/712/C
480
- https://codeforces.com/problemset/problem/621/C
481
- https://codeforces.com/problemset/problem/571/A
482
- https://codeforces.com/problemset/problem/369/E
483
- https://codeforces.com/problemset/problem/1644/D
484
- https://codeforces.com/problemset/problem/1638/D
485
- https://codeforces.com/problemset/problem/1672/D
486
- https://codeforces.com/problemset/problem/1759/G 求字典序最小,通常可以从大往小思考
487
- https://codeforces.com/contest/1882/problem/B
480
+ https://codeforces.com/problemset/problem/1792/C 1500
481
+ - 相似题目 https://codeforces.com/problemset/problem/1367/F1 2100
482
+ https://codeforces.com/problemset/problem/1882/B
483
+ https://codeforces.com/problemset/problem/712/C 1600
484
+ https://codeforces.com/problemset/problem/621/C 1700
485
+ https://codeforces.com/problemset/problem/1644/D 1700
486
+ https://codeforces.com/problemset/problem/1672/D 1700
487
+ https://codeforces.com/problemset/problem/1759/G 1900 求字典序最小,通常可以从大往小思考
488
+ https://codeforces.com/problemset/problem/1638/D 2000
489
+ https://codeforces.com/problemset/problem/571/A 2100
490
+ https://codeforces.com/problemset/problem/369/E 2200
488
491
489
492
删除变添加
490
493
https://codeforces.com/problemset/problem/295/B
@@ -963,25 +966,27 @@ func _() {
963
966
_ = distanceSum
964
967
}
965
968
966
- // 同余前缀和,a 的下标从 0 开始,k 为模数
969
+ // 同余前缀和,a 的下标从 0 开始,md 为模数
970
+ // 求 a[i]+a[i+md]+a[i+2*md]+...
967
971
// 具体用法见 query 上的注释
968
- // LC1664 https://leetcode-cn.com/problems/ways-to-make-a-fair-array/
972
+ // LC1664 https://leetcode.cn/problems/ways-to-make-a-fair-array/
973
+ // LC2902 https://leetcode.cn/problems/count-of-sub-multisets-with-bounded-sum/
969
974
// https://atcoder.jp/contests/abc288/tasks/abc288_d
970
- groupPrefixSum := func (a []int , k int ) {
971
- sum := make ([]int , len (a ) + k )
972
- for i , v := range a {
973
- sum [i + k ] = sum [i ] + v
974
- }
975
- pre := func (x , t int ) int {
976
- if x % k <= t {
977
- return sum [x / k * k + t ]
975
+ groupPrefixSum := func (_a []int , md int ) {
976
+ _sum := make ([]int , len (_a ) + md )
977
+ for i , v := range _a {
978
+ _sum [i + md ] = _sum [i ] + v
979
+ }
980
+ _pre := func (x , t int ) int {
981
+ if x % md <= t {
982
+ return _sum [x / md * md + t ]
978
983
}
979
- return sum [(x + k - 1 )/ k * k + t ]
984
+ return _sum [(x + md - 1 )/ md * md + t ]
980
985
}
981
- // 求下标在 [l,r) 范围内且下标模 k 同余于 t 的所有元素之和
982
- query := func (l , r , t int ) int {
983
- t %= k
984
- return pre (r , t ) - pre (l , t )
986
+ // 求下标在 [l,r) 范围内 & 下标模 md 同余于 rem 的所有元素之和
987
+ query := func (l , r , rem int ) int {
988
+ rem %= md
989
+ return _pre (r , rem ) - _pre (l , rem ) // % mod
985
990
}
986
991
_ = query
987
992
}
0 commit comments