Skip to content

Commit d51adba

Browse files
committed
add links
1 parent 2cfd52c commit d51adba

File tree

2 files changed

+30
-24
lines changed

2 files changed

+30
-24
lines changed

copypasta/common.go

+29-24
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ https://codeforces.com/problemset/problem/1296/C
7777
前后缀分解
7878
- [42. 接雨水](https://leetcode.cn/problems/trapping-rain-water/)([视频讲解](https://www.bilibili.com/video/BV1Qg411q7ia/?t=3m05s))
7979
- [238. 除自身以外数组的乘积](https://leetcode.cn/problems/product-of-array-except-self/)
80+
- [2906. 构造乘积矩阵](https://leetcode.cn/problems/construct-product-matrix/)
8081
- [2256. 最小平均差](https://leetcode.cn/problems/minimum-average-difference/) 1395
8182
- [2483. 商店的最少代价](https://leetcode.cn/problems/minimum-penalty-for-a-shop/) 1495
8283
- [2420. 找到所有好下标](https://leetcode.cn/problems/find-all-good-indices/) 1695
@@ -476,15 +477,17 @@ LC936 https://leetcode.cn/problems/stamping-the-sequence/
476477
LC1199 https://leetcode.cn/problems/minimum-time-to-build-blocks/
477478
LC2382 https://leetcode.cn/problems/maximum-segment-sum-after-removals/
478479
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
488491
489492
删除变添加
490493
https://codeforces.com/problemset/problem/295/B
@@ -963,25 +966,27 @@ func _() {
963966
_ = distanceSum
964967
}
965968

966-
// 同余前缀和,a 的下标从 0 开始,k 为模数
969+
// 同余前缀和,a 的下标从 0 开始,md 为模数
970+
// 求 a[i]+a[i+md]+a[i+2*md]+...
967971
// 具体用法见 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/
969974
// 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]
978983
}
979-
return sum[(x+k-1)/k*k+t]
984+
return _sum[(x+md-1)/md*md+t]
980985
}
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
985990
}
986991
_ = query
987992
}

copypasta/rand.go

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ https://codeforces.com/problemset/problem/1314/D 推荐
1414
https://codeforces.com/problemset/problem/1523/D
1515
Kick Start 2021 Round C Binary Operator https://codingcompetitions.withgoogle.com/kickstart/round/0000000000435c44/00000000007ec290
1616
https://codeforces.com/problemset/problem/1689/D https://www.luogu.com.cn/blog/wangxiwen/solution-cf1689d
17+
https://atcoder.jp/contests/abc272/tasks/abc272_g
1718
1819
xor hashing
1920
https://codeforces.com/problemset/problem/1830/C

0 commit comments

Comments
 (0)