Polynomial Evaluation
Time limit1sMemory limit1024 MB
Given a polynomial of degree N and a prime P, print f(x) mod P for every x from 0 to P-1.
- Level
Medium5 of 10
- Topics
- Number theory, Math, Array
- Solved
- No attempts yet
Problem
A polynomial of degree and a prime are given. A prime is a number divisible only by and itself. is not prime.
Write a program that computes , , , . Here is the remainder when is divided by .
Input
The first line contains two integers and (, , is prime), separated by a space.
The second line contains integers (), separated by spaces.
Output
Print lines. The -th line contains .