Number Game
Practice
3 (2 votes)
Mathematics
Hard
Fast fourier transform
Linear algebra
Problem
20% Success 89 Attempts 50 Points 4s Time Limit 256MB Memory 1024 KB Max Code

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

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

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:50
9 votes
Tags:
Linear AlgebraHardFast Fourier transformTreeMathematics
Points:50
7 votes
Tags:
ArraysLinear AlgebraImplementationFast Fourier transformCombinatoricsFourier TransformationsModular exponentiationMathematicsModulo arithmeticMath
Points:50
Tags:
Linear AlgebrafftFast Fourier transformHardMathematics