/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 5ms 532.0 KiB
#3 Accepted 20ms 532.0 KiB
#4 Accepted 16ms 532.0 KiB
#5 Accepted 13ms 532.0 KiB
#6 Accepted 38ms 532.0 KiB
#7 Accepted 13ms 532.0 KiB

Code

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

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

long long toNum(string s){
    long long num = 0;
    for(int i = 0 ; i < s.size() ; i++){
        num = (num * 10) + (s[i] - '0');
    }
    return num;
}


void solve(){
    int n;
    cin >> n;
    vector<ll> v(n);
    vector<int> tr(11);
    for(int i = 0 ; i < n ; i++){
        cin >> v[i];
        tr[i+1] = 0;
    }

    long long mod = 1e9+7, res = 1;
	
    for(int i = 0 ; i < (1 << n) ; i++){
        bitset<32> b(i);

        ll cur = 0, ct = 0;
        for(int j = n - 1;j>=0;j--){
            if(b[j] == 1){
            	ct++;
            	//cout << v[j] << " ";
                cur = __gcd(v[j], cur);
                cur %= mod;
            }
        }
        tr[ct] += cur;
    }
    for(int i = 1; i <= 10 ; i++){
    	//cout << i << " " <<  tr[i] << endl;
    	if(tr[i])    res *= tr[i];
    	res %= mod;
    }	
    cout << res << endl;
}

int main(){
    ios_base::sync_with_stdio(0), cin.tie(0);
    int t = 1;
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

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 07:02:41
Judged At
2025-09-01 07:02:41
Judged By
Score
100
Total Time
38ms
Peak Memory
532.0 KiB