RubrikOA #16
Stock Prices
估计中等可在线判题
Count the triplets of increasing indices (i,j,k) such that the sum of the prices on those three days is divisible by d. Different index combinations with the same prices are counted separately.
输入格式
The first line contains n d; the second line contains n positive integer prices. Original constraints: n≤1000, price≤10^9, 2≤d≤10^6.
输出格式
Output the number of index triplets that satisfy the condition.
样例 1
输入:
5 5
3 3 4 7 8
输出:
3
样例 2
输入:
3 3
1 1 1
输出:
1
样例 3
输入:
6 2
1 2 3 4 5 6
输出:
10