#P1224. Dot Product Divisibility
Dot Product Divisibility
Dot Product Divisibility
Given n d-dimensional vectors \(x_1, x_2, \ldots, x_n\), determine whether there exists a pair of distinct vectors whose dot product is a multiple of \(k\). The dot product of two vectors \(A=[a_1,a_2,\ldots,a_d]\) and \(B=[b_1,b_2,\ldots,b_d]\) is defined as:
$$ (A,B)=\sum_{i=1}^d a_ib_i = a_1b_1+a_2b_2+\ldots+a_db_d $$
If there exists such a pair \((x_i,x_j)\) for which the dot product \((x_i,x_j)\) is divisible by \(k\), output Yes; otherwise, output No.
inputFormat
The first line contains three integers \(n\), \(d\), and \(k\) — the number of vectors, the dimension of each vector, and the divisor respectively.
Each of the next \(n\) lines contains \(d\) space-separated integers representing the coordinates of a d-dimensional vector.
outputFormat
Output a single line containing Yes if there exists at least one pair of distinct vectors whose dot product is a multiple of \(k\); otherwise, output No.
sample
3 2 3
1 2
2 3
3 4
Yes