Language: C++

#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
typedef long long ll;
int prime[maxn + 1];
int visit[maxn + 1];
void Prime(){
    memset(visit, 0, sizeof(visit));
    memset(prime, 0, sizeof(prime));
    for (int i = 2;i <= maxn; i++) {
//        cout<<" i = "<<i<<endl;
        if (!visit[i]) {
            prime[++prime[0]] = i;      //纪录素数， 这个prime[0] 相当于 cnt，用来计数
        }
        for (int j = 1; j <=prime[0] && i*prime[j] <= maxn; j++) {
//            cout<<"  j = "<<j<<" prime["<<j<<"]"<<" = "<<prime[j]<<" i*prime[j] = "<<i*prime[j]<<endl;
            visit[i*prime[j]] = 1;
            if (i % prime[j] == 0) {
                break;
            }
        }
    }
}
int n, a[maxn];
int num[maxn];
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    Prime();
    bool f = true;
    for (int i = 1; i <= n; i++) {
        int p = a[i];
        for (int j = 1; j <= prime[0] && p >= prime[j]; j++) {
            if(p % prime[j] == 0) {
                if(num[prime[j]]) f = false;
                num[prime[j]] = 1;
                while (p % prime[j] == 0) p /= prime[j];
                if(p == 1) break;
            }
            if(!visit[p]) {
                if(num[p]) f = false;
                num[p] = 1;
                break;
            }
        }
    }
    int gcd = a[1];
    for (int i = 2; i <= n; i++) gcd = __gcd(gcd, a[i]);
    if(f) printf("pairwise coprime\n");
    else if(!f && gcd == 1) printf("setwise coprime\n");
    else printf("not coprime\n");
}


Compiler output:
a.cc: In function 'void Prime()':
a.cc:8:12: error: reference to 'visit' is ambiguous
    8 |     memset(visit, 0, sizeof(visit));
      |            ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:6:5: note:                 'int visit [1000008]'
    6 | int visit[maxn + 1];
      |     ^~~~~
a.cc:8:29: error: reference to 'visit' is ambiguous
    8 |     memset(visit, 0, sizeof(visit));
      |                             ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:6:5: note:                 'int visit [1000008]'
    6 | int visit[maxn + 1];
      |     ^~~~~
a.cc:12:14: error: reference to 'visit' is ambiguous
   12 |         if (!visit[i]) {
      |              ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:6:5: note:                 'int visit [1000008]'
    6 | int visit[maxn + 1];
      |     ^~~~~
a.cc:17:13: error: reference to 'visit' is ambiguous
   17 |             visit[i*prime[j]] = 1;
      |             ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:6:5: note:                 'int visit [1000008]'
    6 | int visit[maxn + 1];
      |     ^~~~~
a.cc: In function 'int main()':
a.cc:40:17: error: reference to 'visit' is ambiguous
   40 |             if(!visit[p]) {
      |                 ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:6:5: note:                 'int visit [1000008]'
    6 | int visit[maxn + 1];
      |     ^~~~~