#P8649. [蓝桥杯 2017 省 B] k 倍区间

[蓝桥杯 2017 省 B] k 倍区间

Problem Description

Given a sequence of length NN, A1,A2,ANA_1, A_2, \cdots A_N. If the sum of a consecutive subsequence Ai,Ai+1,Aj(ij)A_i, A_{i+1}, \cdots A_j (i \le j) is a multiple of KK, then we call the interval [i,j][i, j] a KK-multiple interval.

Can you find how many KK-multiple intervals there are in the sequence?

Input Format

The first line contains two integers NN and KK (1N,K105)(1 \le N, K \le 10^5).

The next NN lines each contain one integer AiA_i (1Ai105)(1 \le A_i \le 10^5).

Output Format

Output one integer, representing the number of KK-multiple intervals.

5 2
1  
2  
3  
4  
5  
6

Hint

Time limit: 2 seconds, 256M. The 8th Lanqiao Cup 2017.

Translated by ChatGPT 5