#C11391. Divisible Pairs
Divisible Pairs
Divisible Pairs
You are given an array of N integers, \(A = [A_1, A_2, \ldots, A_N]\), and an integer \(M\). Your task is to determine the number of distinct pairs \((i, j)\) such that \(1 \leq i < j \leq N\) and the sum \(A_i + A_j\) is divisible by \(M\), i.e.,
\( (A_i + A_j) \mod M = 0 \).
This problem tests your ability to efficiently count pairs based on modular arithmetic properties.
inputFormat
The first line of the input contains two integers, \(N\) and \(M\), where \(N\) is the number of elements in the array and \(M\) is the divisor.
The second line contains \(N\) space-separated integers representing the array \(A\).
Input is provided via standard input (stdin).
outputFormat
Output a single integer representing the number of distinct pairs \((i, j)\) with \(i < j\) for which \(A_i + A_j\) is divisible by \(M\).
Output should be printed to standard output (stdout).
## sample5 4
1 2 3 4 5
2