cf传送门
题意
给定一个串和
w
w
w,多组询问
每次给出
l
,
r
,
k
l,r,k
l,r,k,求出
L
1
L1
L1,
L
2
L2
L2,满足:
[
v
(
L
1
,
L
1
+
w
−
1
)
⋅
v
(
l
i
,
r
i
)
+
v
(
L
2
,
L
2
+
w
−
1
)
]
m
o
d
9
=
k
[v(L_1, L_1+w-1) \cdot v(l_i, r_i) + v(L_2, L_2 + w - 1)]\ mod\ 9=k
[v(L1,L1+w−1)⋅v(li,ri)+v(L2,L2+w−1)] mod 9=k
L
1
L1
L1为第一关键字,
L
2
L2
L2为第二关键字,要求最小化
思路
预处理
h
i
=
(
∑
j
=
i
i
+
w
−
1
a
j
)
m
o
d
9
h_i=(\sum_{j=i}^{i+w-1}{a_j})\ mod \ 9
hi=(∑j=ii+w−1aj) mod 9
每组询问,枚举
v
(
L
1
,
L
1
+
w
−
1
)
m
o
d
9
v(L_1, L_1+w-1) \ mod \ 9
v(L1,L1+w−1) mod 9即可
06-29
1044
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
12-19
1236
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-06
671
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-04
398
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-03
1083
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)