/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 8ms 536.0 KiB
#3 Accepted 45ms 576.0 KiB
#4 Accepted 35ms 652.0 KiB
#5 Accepted 33ms 648.0 KiB
#6 Accepted 31ms 624.0 KiB
#7 Accepted 55ms 532.0 KiB

Code

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using OrderedSet = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define v vector
#define int long long
#define vin vector <int>
#define pii pair <int, int>
#define all(a) a.begin(), a.end()
#define yes cout << "YES\n"
#define Yes cout << "Yes\n"
#define no cout << "NO\n"
#define No cout << "No\n"
#define rep(i, a, b) for(int i = a; i < b; i++)
#define repn(i, a, b) for(int i = a; i <= b; i++)
#define rev(i, a, b) for(int i = a; i >= b; i--)
int mod = 1e9+7;

void fastIO(){
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}

void pk() {
    int n; cin >> n;
    vin p(n);
    rep(i, 0, n) cin >> p[i];
    v<vin> s(1<<n);
    rep(i, 0, 1<<n){
        rep(j, 0, n){
            if(i&1<<j){
                s[i].push_back(p[j]);
            }
        }
    }
    int ans = 1;
    vin gc(n);
    rep(i, 0, 1<<n){
        int g = 0;
        int a = s[i].size();
        rep(j, 0, a){
            g = __gcd(g, s[i][j]);
        }
        gc[a-1] += g;
    }
    rep(i, 0, n) ans = (ans*gc[i])%mod;
    cout << ans <<'\n';
}

int32_t main(){
    fastIO();
    int t = 1;
    cin >> t;
    while(t--) pk();
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1105 Ohh that gcd again
Contest
LUCC Presents Intra LU Junior Programming Contest - Replay
Language
C++17 (G++ 13.2.0)
Submit At
2025-09-02 16:21:48
Judged At
2025-09-02 16:21:48
Judged By
Score
100
Total Time
55ms
Peak Memory
652.0 KiB