Language: C++

#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */

vector<long long> PrimeFactorize(long long n){
  vector<bool> prime(round(sqrt(n))+1,1);
  vector<long long> ans;
  for(long long i=2;i*i<=n;i++){
    if(prime[i]){
      for(long long j=2*i;j*j<=n;j+=i){
        prime[j] = 0;
      }
      while(n%i==0){
        ans.push_back(i);
        n /= i;
      }
    }
  }
  if(n != 1)ans.push_back(n);
  return ans;
}

/* main */

signed main(){
    auto start = std::chrono::system_clock::now();
    ll N;
    cin >> N;
    vl a(N+1);
    FOR(i,0,N+1)cin >> a[i];
    vl primes = PrimeFactorize(abs(a[N]));
    set<ll> s;
    for(auto p:primes)s.insert(p);
    vl v,v2;
    for(auto x:s)v.push_back(x);
    reverse(ALL(a));
    random_device rnd;
    auto end = std::chrono::system_clock::now();
    auto dur = end - start;
    auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(dur).count();
    map<ll,bool> m;
    while(true){
        v2 = vl(0);
        end = std::chrono::system_clock::now();
        dur = end - start;
        msec = std::chrono::duration_cast<std::chrono::milliseconds>(dur).count();
        if(msec > 1900)break;
        ll r = rnd();
        r %= INF;
        for(auto p:v){
            if(p == 0){
                continue;
            }
            ll f = 0;
            ll x = 1;
            FOR(i,0,N+1){
                f += (x * a[i]) % p;
                f %= p;
                x *= r;
                x %= p;
            }
            if(!f)v2.push_back(p);
        }
        v = v2;
    }
    sort(ALL(v));
    for(auto x:v)cout << x << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:90:23: error: 'std::chrono' has not been declared
   90 |     auto start = std::chrono::system_clock::now();
      |                       ^~~~~~
a.cc:101:5: error: 'random_device' was not declared in this scope; did you mean 'random_data'?
  101 |     random_device rnd;
      |     ^~~~~~~~~~~~~
      |     random_data
a.cc:102:21: error: 'std::chrono' has not been declared
  102 |     auto end = std::chrono::system_clock::now();
      |                     ^~~~~~
a.cc:104:22: error: 'std::chrono' has not been declared
  104 |     auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(dur).count();
      |                      ^~~~~~
a.cc:104:49: error: 'std::chrono' has not been declared
  104 |     auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(dur).count();
      |                                                 ^~~~~~
a.cc:108:20: error: 'std::chrono' has not been declared
  108 |         end = std::chrono::system_clock::now();
      |                    ^~~~~~
a.cc:110:21: error: 'std::chrono' has not been declared
  110 |         msec = std::chrono::duration_cast<std::chrono::milliseconds>(dur).count();
      |                     ^~~~~~
a.cc:110:48: error: 'std::chrono' has not been declared
  110 |         msec = std::chrono::duration_cast<std::chrono::milliseconds>(dur).count();
      |                                                ^~~~~~
a.cc:112:16: error: 'rnd' was not declared in this scope; did you mean 'rand'?
  112 |         ll r = rnd();
      |                ^~~
      |                rand