#C8703. Pair Sum Divisibility
Pair Sum Divisibility
Pair Sum Divisibility
You are given an array of N integers and an integer K. Your task is to determine whether there exists a pair of distinct indices i and j (with i < j) such that the sum of the corresponding elements is divisible by K. In other words, you need to check if there exists a pair such that:
\(A_i + A_j \equiv 0 \pmod{K}\)
If such a pair exists, output YES
; otherwise, output NO
.
Note: The input will be read from standard input and the output should be printed to standard output.
inputFormat
The first line of input contains two space-separated integers N and K.
The second line contains N space-separated integers representing the array A.
\(1 \leq N \leq 10^5\), \(1 \leq A_i, K \leq 10^9\).
outputFormat
Print a single line containing YES
if there exists a pair such that the sum of the two numbers is divisible by K, otherwise print NO
.
5 4
1 2 3 4 5
YES
</p>