SOLVE
LATER
You are given \(N+1\) distinct positive integers \(A_1,A_2,......,A_{N+1}\) and a positive integer \(M\). A polynomial of degree \(N\) is defined as follows:
\(f(x)= P_1x^N + P_2x^{N-1} + ……..+ P_Nx + P_{N+1} \)
such that following conditions hold true:
\(f(A_i) = A_i^{N+1} \ \forall i\in [1,N+1]\)
\(P_1 > 0\)
\(P_1,P_2,.....,P_{N+1}\) are integers
A new polynomial is defined as
\(S(x) = X_1x^N + X_2x^{N-1} + ……..+ X_Nx + X_{N+1} \)
Such that \(X_i = |P_i|\%M \ \ \forall i\in [1,N+1]\) and \(X_1,X_2,.......,X_{N+1}\) are integers.
Evaluate \(S(0)\%M, S(1)\%M ,…….S(M-1)\%M\) .
Input format
Output format
Constraints
\(1 \le N,M, A_i \le 10^5\)
\(M\) is prime
Subtasks
Required polynomial \(F(x)\) is \(6x^2 - 11x + 6\) and hence \(S(x)\) is \(6x^2 + 11x + 6\). Hence \(S(0)\% M = 6\), \(S(1)\%M = 23\%13 = 10\) and so on.