#abc156f. F - Modularness
F - Modularness
Score : points
问题描述
我们有一序列 个数:。
按顺序处理以下 个查询:
- 第 个查询包含三个整数 , 和 。令由 个数构成的序列 如下所示:[ \begin{aligned} a_j = \begin{cases} x_i & ( j = 0 ) \ a_{j - 1} + d_{(j - 1)~\text{mod}~k} & ( 0 < j \leq n_i - 1 ) \end{cases}\end{aligned} ] 输出满足条件 的所有 的数量,其中 。
这里 表示两个整数 和 中 除以 后的余数。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
We have a sequence of numbers: .
Process the following queries in order:
- The -th query contains three integers , , and . Let be the following sequence of numbers: [ \begin{aligned} a_j = \begin{cases} x_i & ( j = 0 ) \ a_{j - 1} + d_{(j - 1)~\textrm{mod}~k} & ( 0 < j \leq n_i - 1 ) \end{cases}\end{aligned} ] Print the number of such that $(a_j~\textrm{mod}~m_i) < (a_{j + 1}~\textrm{mod}~m_i)$.
Here denotes the remainder of divided by , for two integers and .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print lines.
The -th line should contain the response to the -th query.
Sample Input 1
3 1
3 1 4
5 3 2
Sample Output 1
1
For the first query, the sequence {} will be .
Thus, the response to this query should be .
Sample Input 2
7 3
27 18 28 18 28 46 1000000000
1000000000 1 7
1000000000 2 10
1000000000 3 12
Sample Output 2
224489796
214285714
559523809
update @ 2024/3/10 17:16:32
相关
在下列比赛中: