Language: C++

#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[100005];
bool U[100005];

ll gcd(ll a, ll b)
{
    if (a < b)
        swap(a, b);
    ll c = a % b;
    if (c == 0)
        return b;
    return gcd(b, c);
}

int main()
{
    int N;
    cin >> N;
    REP(i, N + 1)
    {
        cin >> A[i];
    }

    ll g = abs(A[0]);
    REP(i, N)
    {
        if (A[i + 1] == 0)
            continue;
        g = gcd(g, abs(A[i + 1]));
    }

    vector<ll> prime;
    for (int i = 2; i <= 100000; ++i)
    {
        if (U[i])
            continue;
        prime.push_back(i);
        for (int j = i; j <= 100000; j += i)
            U[j] = true;
    }
    vector<ll> a;
    REP(i, N + 1)
    {
        A[i] /= g;
    }

    REP(i, std::min(prime.size(),1000))
    {
        bool f = true;
        REP(n, 2)
        {
            ll t = 1;
            ll sum = 0;
            REP(j, N + 1)
            {
                //cout<<A[N-j]<<endl;
                sum += (t * A[N - j]) % prime[i];
                sum %= prime[i];
                t *= n;
                t % prime[i];
                //cout<<"s"<<sum<<endl;
            }
            if (sum != 0)
            {
                f = false;
                break;
            }
        }
        if (f)
            a.push_back(prime[i]);
    }

    REP(i, prime.size())
    {
        if (g % prime[i] == 0)
            a.push_back(prime[i]);
        while (g % prime[i] == 0)
            g /= prime[i];
    }
    if (g > 1)
        a.push_back(g);

    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
    REP(i, a.size())
    {
        cout << a[i] << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:59:20: error: no matching function for call to 'min(std::vector<long long int>::size_type, int)'
   59 |     REP(i, std::min(prime.size(),1000))
      |            ~~~~~~~~^~~~~~~~~~~~~~~~~~~
a.cc:7:47: note: in definition of macro 'FOR'
    7 | #define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
      |                                               ^
a.cc:59:5: note: in expansion of macro 'REP'
   59 |     REP(i, std::min(prime.size(),1000))
      |     ^~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:59:20: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'int')
   59 |     REP(i, std::min(prime.size(),1000))
      |            ~~~~~~~~^~~~~~~~~~~~~~~~~~~
a.cc:7:47: note: in definition of macro 'FOR'
    7 | #define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
      |                                               ^
a.cc:59:5: note: in expansion of macro 'REP'
   59 |     REP(i, std::min(prime.size(),1000))
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:59:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
   59 |     REP(i, std::min(prime.size(),1000))
      |            ~~~~~~~~^~~~~~~~~~~~~~~~~~~
a.cc:7:47: note: in definition of macro 'FOR'
    7 | #define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
      |                                               ^
a.cc:59:5: note: in expansion of macro 'REP'
   59 |     REP(i, std::min(prime.size(),1000))
      |     ^~~