#include <iostream> #include <cstdio> #include <vector> using namespace std; const int MaxN = 100; typedef unsigned long long u64; const int NM = 2; const int M[NM] = {-1, 999946333}; int main() { //freopen("equation.in", "r", stdin); //freopen("equation.out", "w", stdout); int n, m; static u64 a[NM][MaxN + 1]; cin >> n >> m; for (int i = 0; i <= n; i++) { bool isNeg = false; char c; while (c = getchar(), !(('0' <= c && c <= '9') || c == '-')); if (c == '-') { isNeg = true; c = getchar(); } for (int k = 0; k < NM; k++) a[k][i] = 0; do { a[0][i] = a[0][i] * 10 + (c - '0'); a[0][i] %= 0x7fffffff; a[1][i] = (a[1][i] * 10 + (c - '0')) % M[1]; } while (c = getchar(), '0' <= c && c <= '9'); if (isNeg) { if (a[0][i] != 0) a[0][i] = 0x7fffffff - a[0][i]; if (a[1][i] != 0) a[1][i] = M[1] - a[1][i]; } } vector<int> res; for (int x = 1; x <= m; x++) { register u64 y; y = 0; for (int i = n; i >= 0; i--) { y = y * x + a[0][i]; y = (y & 0x7fffffff) + (y >> 31); } y %= 0x7fffffff; if (y != 0) continue; y = 0; for (int i = n; i >= 0; i--) y = (y * x + a[1][i]) % M[1]; if (y != 0) continue; res.push_back(x); } printf("%d\n", (int)res.size()); for (int i = 0; i < (int)res.size(); i++) printf("%d\n", res[i]); return 0; } /************************************************************** Problem: 2339 User: admin Language: C++ Result: Accepted Time:635 ms Memory:2080 kb ****************************************************************/