100 atcoder#ABC105D. [ABC105D] Candy Distribution
[ABC105D] Candy Distribution
Score : points
Problem Statement
There are boxes arranged in a row from left to right. The -th box from the left contains candies.
You will take out the candies from some consecutive boxes and distribute them evenly to children.
Such being the case, find the number of the pairs that satisfy the following:
- and are both integers and satisfy .
- is a multiple of .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number of the pairs that satisfy the conditions.
Note that the number may not fit into a -bit integer type.
3 2
4 1 5
3
The sum for each pair is as follows:
- Sum for :
- Sum for :
- Sum for :
- Sum for :
- Sum for :
- Sum for :
Among these, three are multiples of .
13 17
29 7 5 7 9 51 7 13 8 55 42 9 81
6
10 400000000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
25