#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "testlib.h" using namespace std; #define rep(i,n,c) for (int i=0;i using vec = vector; template using vvec = vec>; template using vvvec = vec>; using ll = long long; using pii = pair; using pll = pair; template bool chmin(T &a, T b){ if (a>b){ a = b; return true; } return false; } template bool chmax(T &a, T b){ if (a T sum(vec x){ T res=0; for (auto e:x){ res += e; } return res; } template void printv(vec x){ for (auto e:x){ cout< prime = {}; void make_prime(){ calc_spf(); for (int i=2;i<32000;i++){ if (spf[i]==i){ prime.append(i); } } } vec factorization(ll n){ assert (1 <= n); assert (n <= M); vec res; ll cnt = 0; for (auto p:prime){ cnt = 0; while (n%p==0){ cnt += 1; n /= p; } if (cnt!=0){ res.append({p,cnt}); } } if (n!=1){ res.append({n,cnt}); } return res; } vec divisors(vec n_prime){ vec res = {1ll}; ll tmp; for (auto [p,cnt]:n_prime){ vec new_res; for (auto d:res){ tmp = d; for (int i=0;i>= 1; } return res; } int main(int argc, char* argv[]){ registerValidation(argc,argv); ios::sync_with_stdio(false); std::cin.tie(nullptr); make_prime(); int N; N = inf.readInt(1,2000); inf.readEoln(); vec A(N); map lcm_A; set all_divisors; set check; for (int i=0;i P(0); for (auto [p,cnt]:lcm_A){ P.append(pow(p,cnt)); } int n = P.size(); deque deq = {{1,-1}}; ll prod = -1; while (!deq.empty()){ auto [v,k] = deq.front(); deq.pop_front(); for (int i=k+1;i selected_P(0); for (auto p:P){ if (prod%p==0){ selected_P.append(p); } } int k = selected_P.size(); vec> S(k,vec(0)); for (auto a:A){ for (int i=0;i