100 atcoder#ABC146E. [ABC146E] Rem of Sum is Num
[ABC146E] Rem of Sum is Num
Score : points
Problem Statement
Given are a sequence of positive integers , and a positive integer .
Find the number of non-empty contiguous subsequences in such that the remainder when dividing the sum of its elements by is equal to the number of its elements. We consider two subsequences different if they are taken from different positions, even if they are equal sequences.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number of subsequences that satisfy the condition.
5 4
1 4 2 3 5
4
Four sequences satisfy the condition: , , , and .
8 4
4 2 4 2 4 2 4 2
7
is counted four times, and is counted three times.
10 7
14 15 92 65 35 89 79 32 38 46
8