#P2312. [NOIP 2014 提高组] 解方程

    ID: 1278 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>数学高精度2014NOIp 提高组枚举,暴力素数判断,质数,筛法

[NOIP 2014 提高组] 解方程

Description

Given the polynomial equation:

a0+a1x+a2x2++anxn=0a_0+a_1x+a_2x^2+\cdots+a_nx^n=0

Find all integer solutions of this equation in [1,m][1,m] (both nn and mm are positive integers).

Input Format

The input contains n+2n + 2 lines.
The first line contains two integers n,mn, m, separated by a single space.
Each of the next n+1n + 1 lines contains one integer, namely a0,a1,a2,,ana_0, a_1, a_2, \ldots, a_n in order.

Output Format

On the first line, output the number of integer solutions in [1,m][1,m].
Then output each integer solution in [1,m][1,m] in increasing order, one per line.

2 10 
1
-2
1
1
1
2 10
2
-3
1
2
1
2
2 10
1
3
2
0

Hint

For 30%30\% of the testdata: 0<n2,ai100,an0,m<1000<n\le 2,|a_i|\le 100,a_n≠0,m<100
For 50%50\% of the testdata: 0<n100,ai10100,an0,m<1000<n\le 100,|a_i|\le 10^{100},a_n≠0,m<100
For 70%70\% of the testdata: 0<n100,ai1010000,an0,m<1040<n\le 100,|a_i|\le 10^{10000},a_n≠0,m<10^4
For 100%100\% of the testdata: 0<n100,ai1010000,an0,m<1060<n\le 100,|a_i|\le 10^{10000},a_n≠0,m<10^6

Translated by ChatGPT 5