/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 536.0 KiB
#2 Accepted 7ms 532.0 KiB
#3 Accepted 28ms 532.0 KiB
#4 Accepted 26ms 532.0 KiB
#5 Accepted 24ms 532.0 KiB
#6 Accepted 23ms 532.0 KiB
#7 Accepted 49ms 496.0 KiB

Code

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

#define ll long long
#define endl '\n'

const int nn = 15, mod = 1e9 + 7;
int n, A[nn];

void Try() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> A[i];
    }
    
    int ans = 1;
    
    vector<vector<int>> SS;
    SS.push_back({});
    for (int i = 1; i <= n; i++) {
        vector<vector<int>> TSS;
        for (int j = 0; j < SS.size(); j++) {
            SS[j].push_back(A[i]);
            TSS.push_back(SS[j]);
            SS[j].pop_back();
        }
        
        for (auto v : TSS) {
            SS.push_back(v);
        }
        
    }
    
    
    vector<int>V(n + 1, 0);
    for (auto v : SS) {
        if (v.size()) {
            int g = 0;
            for (auto x : v) {
                g = gcd(x, g);
            }
            V[v.size()] += g;
        }
    }
    
    
    for (int i = 1; i <= n; i++) {
        ans = 1LL * ans * V[i] % mod;    
    }
    
    cout << ans << endl;
    
}

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0);

    int t = 1;
    cin >> t;
    for (int i = 1; i <= t; i++) {
        Try();
    }

}

Information

Submit By
Type
Submission
Problem
P1105 Ohh that gcd again
Contest
LUCC Presents Kick & Code Intra LU Programming Contest
Language
C++17 (G++ 13.2.0)
Submit At
2025-09-01 06:03:43
Judged At
2025-09-01 06:03:43
Judged By
Score
100
Total Time
49ms
Peak Memory
536.0 KiB