← 返回 bytedance 的题目列表Count of Interesting Subarrays
类型:online_judge
Given a 0-indexed integer array nums, and two integers modulo and k.
A subarray nums[l..r] is called interesting if:
cnt % modulo == k
where cnt is the number of indices i in the subarray such that:
nums[i] % modulo == k
Return the number of interesting subarrays.
Input Format
n modulo k
nums[0] nums[1] ... nums[n-1]
Output Format
Print one integer, the number of interesting subarrays.
Example
Input:
4 3 0
3 1 9 6
Output:
2
Constraints
1 <= n <= 10^5
1 <= modulo <= 10^9
0 <= k < modulo
0 <= nums[i] <= 10^9
The answer may exceed the 32-bit integer range.
Example
Input
4 3 0
3 1 9 6
Output
2