P27035 [AtCoder] Polynomial Divisors
提高+
题目描述

Problem Description

Given an integer coefficient polynomial of degree $ N $, $ f(x)=a_Nx^N+a_{N-1}x^{N-1}+...+a_0 $. Find all prime numbers $ p $ that divide $ f(x) $ for any integer $ x $.

Input Format

The input is given from the standard input in the following format:

$ N $ $ a_N $ $ : $ $ a_0 $

Output Format

Output all prime numbers $ p $ that divide $ f(x) $ for any integer $ x $ in ascending order.

Sample Input and Output

Sample Input #1

2
7
-7
14

Sample Output #1

2
7

Sample Input #2

3
1
4
1
5

Sample Output #2

Sample Input #3

0
998244353

Sample Output #3

998244353

Notes/Hints

Constraints

  • $0 \leq N \leq 10^4$
  • $|a_i| \leq 10^9 (0 \leq i \leq N)$
  • $a_N \neq 0$
  • All inputs are integers

Sample Explanation 1

$ 2 $ and $ 7 $ divide, for example, $ f(1)=14 $ and $ f(2)=28 $.

Sample Explanation 2

There may be no prime numbers that satisfy the condition.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
2 7 -7 14
样例输出
2 7