140. Integer Sequences¶
time limit per test: 0.25 sec / memory limit per test: 4096 KB
A sequence A is called an integer sequence of length N if all its elements \(A_1 A_2 .. A_N\) are non-negative integers less than 2 000 000 000. Consider two integer sequences of length N, A and X. The result of their multiplication (A*X) is an integer number \(R=A_1*X_1 + A_2*X_2 + .. + A_N*X_N\). Your task is to solve the equation A*X=B (mod P), given the integer sequence A and the integer numbers B and P.
Input
The first line contains the integer numbers N (1<=N<=100) - the length of the integer sequences - P (1<=P<=10 000) and B (0<=B<=P-1). The second line contains the elements of the sequence A, separated by blanks: \(A_1 A_2 .. A_N\).
Output
You should print one line containing the word “YES” if there exists at least one integer sequence X which is a solution to the equation, or print “NO” otherwise. If the answer is “YES”, the next line should contain N non-negative integers separated by blanks: \(X_1 X_2 .. X_N\).
Example(s)
| Sample Input | Sample Output |
2 7 4
7 3
|
YES
0 6
|
| Sample Input | Sample Output |
3 10 1
2 4 6
|
NO
|