Polynomial Divisors

AtCoder
IDtenka1_2019_e
Time2000ms
Memory256MB
Difficulty
You are given a polynomial of degree $N$ with integer coefficients: $f(x)=a_Nx^N+a_{N-1}x^{N-1}+...+a_0$. Find all prime numbers $p$ that divide $f(x)$ for every integer $x$. ## Constraints * $0 \leq N \leq 10^4$ * $|a_i| \leq 10^9(0\leq i\leq N)$ * $a_N \neq 0$ * All values in input are integers. ## Input Input is given from Standard Input in the following format: $N$ $a_N$ $:$ $a_0$ [samples]
Samples
Input #1
2
7
-7
14
Output #1
2
7

$2$ and $7$ divide, for example, $f(1)=14$ and $f(2)=28$.
Input #2
3
1
4
1
5
Output #2
There may be no integers that satisfy the condition.
Input #3
0
998244353
Output #3
998244353
API Response (JSON)
{
  "problem": {
    "name": "Polynomial Divisors",
    "description": {
      "content": "You are given a polynomial of degree $N$ with integer coefficients: $f(x)=a_Nx^N+a_{N-1}x^{N-1}+...+a_0$. Find all prime numbers $p$ that divide $f(x)$ for every integer $x$.",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "tenka1_2019_e"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given a polynomial of degree $N$ with integer coefficients: $f(x)=a_Nx^N+a_{N-1}x^{N-1}+...+a_0$. Find all prime numbers $p$ that divide $f(x)$ for every integer $x$.\n\n## Constraints\n\n*   $0 \\...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments