cswork / OA打开练习工作台

AmazonOA #189

Find Security Level

估计中等可在线判题

考点(AI 标注)前缀和区间哈希计数双指针滑窗

Count the non-empty contiguous subarrays whose element sum, taken modulo k as a non-negative remainder, equals exactly the subarray length. Under the original numeric constraints elements may be equal, and identity does not affect the sum.

输入格式

The first line contains n k; the second line contains the elements. 1≤n≤200000; 1≤elements,k≤10^9.

输出格式

Output a single integer, the answer.

样例 1

输入:

4 4
1 3 2 4

输出:

2

样例 2

输入:

3 2
1 1 1

输出:

3

样例 3

输入:

1 1
1

输出:

0

样例说明

The answers are 2, 3 and 0.