/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 5ms 532.0 KiB
#3 Accepted 24ms 532.0 KiB
#4 Accepted 20ms 532.0 KiB
#5 Accepted 18ms 532.0 KiB
#6 Accepted 17ms 532.0 KiB
#7 Accepted 11ms 564.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M = 1e9+7;

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int tc; cin >> tc;

    test:
    while (tc--) {
        ll n; cin >> n;
        
        ll arr[n];
        for (auto &u : arr) cin >> u;

        ll cnt[15] = {0};
        for (ll i = 1; i < (1LL << n); i++) {
            ll gcd = 0;
            for (ll j = 0; j < n; j++) if (i & (1LL << j)) gcd = __gcd(gcd, arr[j]);
            cnt[__builtin_popcount(i)] += gcd;
        }

        ll ans = 1;
        for (ll i = 1; i < 15; i++) ans = (ans * max(1LL, cnt[i])) % M;
        cout << ans << "\n";
    }
}

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 15:57:34
Judged At
2025-09-02 15:57:34
Judged By
Score
100
Total Time
24ms
Peak Memory
564.0 KiB