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
- First line: Two space separated integers \(N\) and \(M\)
- Second line: \(N+1\) space separated integers \(A_1,A_2,......,A_{N+1}\)
Output format
- Output \(M\) space-separated integers \(S(0)\%M, S(1)\%M ,…….S(M-1)\%M\)
Constraints
\(1 \le N,M, A_i \le 10^5\)
\(M\) is prime
Subtasks
- For 20 Points: \(1 \le N,M, A_i \le 1000\)
- For 80 Points: Original constraints
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.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor